mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Make the completions for the ls, sed and df commands have the correct switches on BSD systems
darcs-hash:20060114131607-ac50b-479f7ff34019f5487125321443027cc0a77eec93.gz
This commit is contained in:
parent
6d6644b907
commit
9942e2f19f
6 changed files with 212 additions and 99 deletions
|
@ -1111,8 +1111,7 @@ g++, javac, java, gcj, lpr, doxygen, whois, find)
|
|||
\subsection bugs Known bugs
|
||||
|
||||
- Completion for gcc -\#\#\# option doesn't work.
|
||||
- Many completions are made specifically for the GNU
|
||||
version of a POSIX command
|
||||
- Many completions are made specifically for the GNU version of a POSIX command
|
||||
- Yanking weird characters from clipboard prints Unicode escapes
|
||||
- Suspending and then resuming pipelines containing a builtin seems to be broken.
|
||||
- Interactive input seems broken inside blocks. Is local echo and other terminal values not restored when in an interactive block?
|
||||
|
|
|
@ -1,18 +1,43 @@
|
|||
#
|
||||
# Completions for df
|
||||
#
|
||||
|
||||
#
|
||||
# Completions for mount define the $__fish_filesystems variable
|
||||
#
|
||||
complete -y mount
|
||||
|
||||
#
|
||||
# Test if we are using GNU sed
|
||||
#
|
||||
|
||||
set -l is_gnu
|
||||
df --version >/dev/null ^/dev/null; and set is_gnu --is-gnu
|
||||
|
||||
__fish_gnu_complete -c df -s h -l human-readable -d (_ "Human readable sizes") $is_gnu
|
||||
__fish_gnu_complete -c df -s i -l inodes -d (_ "List inode information") $is_gnu
|
||||
__fish_gnu_complete -c df -s k -d (_ "Use 1kB block size") $is_gnu
|
||||
__fish_gnu_complete -c df -s l -l local -d (_ "List only local filesystems") $is_gnu
|
||||
__fish_gnu_complete -c df -s P -l portability -d (_ "Use Posix format") $is_gnu
|
||||
__fish_gnu_complete -c df -s t -l type -r -d (_ "Show filesystems of specified type") $is_gnu -x -a $__fish_filesystems
|
||||
|
||||
if test -n "$is_gnu"
|
||||
|
||||
complete -c df -s a -l all -d (_ "Include empty filesystems")
|
||||
complete -c df -s B -l block-size -r -d (_ "Block size")
|
||||
complete -c df -s h -l human-readable -d (_ "Human readable sizes")
|
||||
complete -c df -s H -l si -d (_ "Human readable sizes, powers of 1000")
|
||||
complete -c df -s i -l inodes -d (_ "List inode information")
|
||||
complete -c df -s k -d (_ "Use 1kB block size")
|
||||
complete -c df -s l -l local -d (_ "List only local filesystems")
|
||||
complete -c df -l no-sync -d (_ "Do not sync before getting usage info")
|
||||
complete -c df -s P -l portability -d (_ "Use Posix format")
|
||||
complete -c df -l sync -d (_ "Sync before getting usage info")
|
||||
complete -c df -s t -l type -r -d (_ "Filesystem type") -x -a $__fish_filesystems
|
||||
complete -c df -s T -l print-type -d (_ "Print filesystem type")
|
||||
complete -c df -s x -l exclude-type -d (_ "Excluded filesystem type") -r -x -a $__fish_filesystems
|
||||
complete -c df -l help -d (_ "Display help and exit")
|
||||
complete -c df -l version -d (_ "Display version and exit")
|
||||
|
||||
else
|
||||
|
||||
complete -c df -s a -d (_ "Show all filesystems")
|
||||
complete -c df -s g -d (_ "Show sizes in gigabytes")
|
||||
complete -c df -s m -d (_ "Show sizes in megabytes")
|
||||
complete -c df -s n -d (_ "Print out the previously obtained statistics from the file systems")
|
||||
|
||||
end
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#
|
||||
# Completions for the grep command
|
||||
#
|
||||
|
||||
complete -c grep -s A -l after-context -d (_ "Print NUM lines of trailing context")
|
||||
complete -c grep -s a -l text -d (_ "Process binary file as text")
|
||||
|
|
|
@ -1,46 +1,66 @@
|
|||
#
|
||||
# Completions for the ls command and its aliases
|
||||
#
|
||||
|
||||
# Test if we are using GNU ls
|
||||
|
||||
set -l is_gnu
|
||||
ls --version >/dev/null ^/dev/null; and set is_gnu --is-gnu
|
||||
|
||||
for i in ls ll la
|
||||
|
||||
complete -c $i -s a -l all -d (_ "Show hidden")
|
||||
complete -c $i -s A -l almost-all -d (_ "Show hidden except . and ..")
|
||||
# Shared ls switches
|
||||
|
||||
__fish_gnu_complete -c $i -s a -l all -d (_ "Show hidden") $is_gnu
|
||||
__fish_gnu_complete -c $i -s A -l almost-all -d (_ "Show hidden except . and ..") $is_gnu
|
||||
__fish_gnu_complete -c $i -s F -l classify -d (_ "Append filetype indicator") $is_gnu
|
||||
__fish_gnu_complete -c $i -s H -l dereference-command-line -d (_ "Follow symlinks") $is_gnu
|
||||
__fish_gnu_complete -c $i -s L -l dereference -d (_ "Follow symlinks") $is_gnu
|
||||
__fish_gnu_complete -c $i -s R -l recursive -d (_ "List subdirectory recursively") $is_gnu
|
||||
__fish_gnu_complete -c $i -s b -l escape -d (_ "Octal escapes for non graphic characters") $is_gnu
|
||||
__fish_gnu_complete -c $i -s d -l directory -d (_ "List directories, not their content") $is_gnu
|
||||
__fish_gnu_complete -c $i -s h -l human-readable -d (_ "Human readable sizes") $is_gnu
|
||||
__fish_gnu_complete -c $i -s i -l inode -d (_ "Print inode number of files") $is_gnu
|
||||
__fish_gnu_complete -c $i -s n -l numeric-uid-gid -d (_ "Long format, numeric IDs") $is_gnu
|
||||
__fish_gnu_complete -c $i -s p -l file-type -d (_ "Append filetype indicator") $is_gnu
|
||||
__fish_gnu_complete -c $i -s q -l hide-control-chars -d (_ "Replace non-graphic characters with '?'") $is_gnu
|
||||
__fish_gnu_complete -c $i -s r -l reverse -d (_ "Reverse sort order") $is_gnu
|
||||
__fish_gnu_complete -c $i -s s -l size -d (_ "Print size of files") $is_gnu
|
||||
|
||||
complete -c $i -s C -d (_ "List by columns")
|
||||
complete -c $i -s S -d (_ "Sort by size")
|
||||
complete -c $i -s c -d (_ "Show and sort by ctime")
|
||||
complete -c $i -s f -d (_ "Don't sort")
|
||||
complete -c $i -s g -d (_ "Long format without owner")
|
||||
complete -c $i -s k -d (_ "Set blocksize to 1kB")
|
||||
complete -c $i -s l -d (_ "Long format")
|
||||
complete -c $i -s m -d (_ "Comma separated format")
|
||||
complete -c $i -s t -d (_ "Sort by modification time")
|
||||
complete -c $i -s u -d (_ "Show access time")
|
||||
complete -c $i -s x -d (_ "List entries by lines")
|
||||
complete -c $i -s 1 -d (_ "List one file per line")
|
||||
|
||||
if test -n "$is_gnu"
|
||||
|
||||
# GNU specific features
|
||||
|
||||
complete -c $i -l author -d (_ "Print author")
|
||||
complete -c $i -s b -l escape -d (_ "Octal escapes for non graphic")
|
||||
complete -c $i -l blocksize -x -d (_ "Set block size")
|
||||
complete -c $i -s B -l ignore-backups -d (_ "Ignore files ending with ~")
|
||||
complete -c $i -s c -d (_ "Show and sort by ctime")
|
||||
complete -c $i -s C -d (_ "List by columns")
|
||||
complete -c $i -l color -f -a "never always auto" -d (_ "Use colors")
|
||||
complete -c $i -s d -l directory -d (_ "List directories, not their content")
|
||||
complete -c $i -s D -l dired -d (_ "Generate dired output")
|
||||
complete -c $i -s f -d (_ "Don't sort")
|
||||
complete -c $i -s F -l classify -d (_ "Append filetype indicator")
|
||||
complete -c $i -l format -x -a "across commas horizontal long single-column verbose vertical" -d (_ "List format")
|
||||
complete -c $i -l full-time -d (_ "Long format, full-iso time")
|
||||
complete -c $i -s g -d (_ "Long format without owner")
|
||||
complete -c $i -s G -l no-group -d (_ "Don't print group information")
|
||||
complete -c $i -s h -l human-readable -d (_ "Human readable sizes")
|
||||
complete -c $i -l si -d (_ "Human readable sizes, powers of 1000")
|
||||
complete -c $i -s H -l dereference-command-line -d (_ "Follow symlinks")
|
||||
complete -c $i -l dereference-command-line-symlink-to-dir #-d (_ "Follow directory symlinks from command line")
|
||||
complete -c $i -l indicator-style -x -a "none classify file-type" -d (_ "Append filetype indicator")
|
||||
complete -c $i -s i -l inode -d (_ "Print inode number of files")
|
||||
complete -c $i -s I -l ignore -r -d (_ "Skip entries matching pattern")
|
||||
complete -c $i -s k -d (_ "Like --block-size=1K")
|
||||
complete -c $i -s l -d (_ "Long format")
|
||||
complete -c $i -s L -l dereference -d (_ "Follow symlinks")
|
||||
complete -c $i -s m -d (_ "Comma separated format")
|
||||
complete -c $i -s n -l numeric-uid-gid -d (_ "Long format, numeric IDs")
|
||||
complete -c $i -s N -l literal -d (_ "Print raw entry names")
|
||||
complete -c $i -s o -d (_ "Long format without groups")
|
||||
complete -c $i -s p -l file-type -d (_ "Append filetype indicator")
|
||||
complete -c $i -s q -l hide-control-chars -d (_ "Replace non-graphic characters with '?'")
|
||||
complete -c $i -l show-control-chars -d (_ "Non graphic as-is")
|
||||
complete -c $i -s Q -l quote-name -d (_ "Enclose entry in quotes")
|
||||
complete -c $i -l quoting-style -x -a "literal locale shell shell-always c escape" -d (_ "Select quoting style")
|
||||
complete -c $i -s r -l reverse -d (_ "Reverse sort order")
|
||||
complete -c $i -s R -l recursive -d (_ "List subdirectory recursively")
|
||||
complete -c $i -s s -l size -d (_ "Print size of files")
|
||||
complete -c $i -s S -d (_ "Sort by size")
|
||||
complete -c $i -l sort -x -d (_ "Sort criteria") -a "
|
||||
extension\t'Sort by file extension'
|
||||
none\tDon't\ sort
|
||||
|
@ -60,16 +80,27 @@ for i in ls ll la
|
|||
status\t'Sort by status time'
|
||||
"
|
||||
complete -c $i -l time-style -x -a "full-iso long-iso iso locale" -d (_ "Select time style")
|
||||
complete -c $i -s t -d (_ "Sort by modification time")
|
||||
complete -c $i -s T -l tabsize -x -a "1 2 3 4 5 6 7 8 9 10 11 12" -d (_ "Assume tab stops at each COLS")
|
||||
complete -c $i -s u -d (_ "Show access time")
|
||||
complete -c $i -s U -d (_ "Do not sort")
|
||||
complete -c $i -s v -d (_ "Sort by version")
|
||||
complete -c $i -s w -l width -x -d (_ "Assume screen width")
|
||||
complete -c $i -s x -d (_ "List entries by lines")
|
||||
complete -c $i -s X -d (_ "Sort by extension")
|
||||
complete -c $i -s 1 -d (_ "List one file per line")
|
||||
complete -c $i -l help -d (_ "Display help and exit")
|
||||
complete -c $i -l version -d (_ "Display version and exit")
|
||||
|
||||
else
|
||||
|
||||
# If not a GNU system, assume we have standard BSD ls features instead
|
||||
|
||||
complete -c $i -s B -d (_ "Octal escapes for non graphic characters")
|
||||
complete -c $i -s G -d (_ "Use colors")
|
||||
complete -c $i -s I -d (_ "Prevent -A from being automatically set for root")
|
||||
complete -c $i -s P -d (_ "Don't follow symlinks")
|
||||
complete -c $i -s T -d (_ "Show modification time")
|
||||
complete -c $i -s W -d (_ "Show whiteouts when scanning directories")
|
||||
complete -c $i -s Z -d (_ "Display each file's MAC label")
|
||||
complete -c $i -s o -d (_ "Include the file flags in a long (-l) output")
|
||||
complete -c $i -s w -d (_ "Print raw entry names")
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,24 @@
|
|||
complete -c sed -s n -l quiet -d (_ "Silent mode")
|
||||
#
|
||||
# Completions for sed
|
||||
#
|
||||
|
||||
# Test if we are using GNU sed
|
||||
|
||||
set -l is_gnu
|
||||
sed --vvversion >/dev/null ^/dev/null; and set is_gnu --is-gnu
|
||||
|
||||
# Shared ls switches
|
||||
|
||||
__fish_gnu_complete -c sed -s n -l quiet -d (_ "Silent mode") $is_gnu
|
||||
__fish_gnu_complete -c sed -s e -l expression -x -d (_ "Evaluate expression") $is_gnu
|
||||
__fish_gnu_complete -c sed -s f -l file -r -d (_ "Evalute file") $is_gnu
|
||||
__fish_gnu_complete -c sed -s i -l in-place -d (_ "Edit files in place") $is_gnu
|
||||
|
||||
if test -n "$is_gnu"
|
||||
|
||||
# GNU specific features
|
||||
|
||||
complete -c sed -l silent -d (_ "Silent mode")
|
||||
complete -c sed -s e -l expression -x -d (_ "Evaluate expression")
|
||||
complete -c sed -s f -l file -r -d (_ "Evalute file")
|
||||
complete -c sed -s i -l in-place -d (_ "Edit files in place")
|
||||
complete -c sed -s l -l line-length -x -d (_ "Specify line-length")
|
||||
complete -c sed -l posix -d (_ "Disable all GNU extensions")
|
||||
complete -c sed -s r -l regexp-extended -d (_ "Use extended regexp")
|
||||
|
@ -10,3 +26,13 @@ complete -c sed -s s -l separate -d (_ "Consider files as separate")
|
|||
complete -c sed -s u -l unbuffered -d (_ "Use minimal IO buffers")
|
||||
complete -c sed -l help -d (_ "Display help and exit")
|
||||
complete -c sed -s V -l version -d (_ "Display version and exit")
|
||||
|
||||
else
|
||||
|
||||
# If not a GNU system, assume we have standard BSD ls features instead
|
||||
|
||||
complete -c sed -s E -d (_ "Use extended regexp")
|
||||
complete -c sed -s a -d (_ "Delay opening files until a command containing the related 'w' function is applied")
|
||||
complete -c sed -s l -d (_ "Use line buffering")
|
||||
|
||||
end
|
||||
|
|
|
@ -237,6 +237,35 @@ function __fish_append -d "Internal completion function for appending string to
|
|||
printf "%s\n" "$str"$argv "$str"(printf "%s\n" $argv|sed -e "s/\(\t\|\$\)/,\1/")
|
||||
end
|
||||
|
||||
function __fish_gnu_complete -d "Wrapper for the complete builtin. Skips the long completions on non-GNU systems"
|
||||
set is_gnu 0
|
||||
|
||||
# Check if we are using a gnu system
|
||||
for i in (seq (count $argv))
|
||||
switch $argv[$i]
|
||||
|
||||
case -g --is-gnu
|
||||
set -e argv[$i]
|
||||
set is_gnu 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
# Remove long option if not on a gnu system
|
||||
if test $is_gnu = 0
|
||||
for i in (seq (count $argv))
|
||||
if test $argv[$i] = -l
|
||||
set -e argv[$i]
|
||||
set -e argv[$i]
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
complete $argv
|
||||
|
||||
end
|
||||
|
||||
#
|
||||
# Completions for SysV startup scripts
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue