From c66ec4df3d57bcbd8eb1fb3d92c3cd80e1c215b5 Mon Sep 17 00:00:00 2001 From: gonchar Date: Fri, 23 Sep 2011 12:24:21 +0400 Subject: [PATCH 1/7] * __fish_complete_subcommand_root now passes arguments to __fish_complete_subcommand * sudo: - now can be completed bu group and user (-u and -g keys). - subcommand completion is fixed * __fish_complete_proc.fish is added to complete killall command with list of running processes * __fish_complete_tex.fish is updated with common options * __fish_make_completion_signals.fish is added to make a list of kill signals for kill and killall * completions: - minor filetype completions are added for djview, xpdf, mupdf, gv, xdvi - adduser is copmleted by user and group - dlocate and dpkg are completed by packages - find: -executable options is added - htop: options - funced and funcsave are completed by function names - ifdown and ifup are copmleted by interfaces - kill and killall: options, signals and processes - latexmk, ln, nm: options - lualatex and xelatex copmletions - sudo: -u and -g options - wvdial: presets --- share/completions/adduser.fish | 9 +++--- share/completions/djview.fish | 3 ++ share/completions/djview3.fish | 3 ++ share/completions/djview4.fish | 3 ++ share/completions/dlocate.fish | 6 ++++ share/completions/dpkg.fish | 6 ++++ share/completions/find.fish | 5 +-- share/completions/funced.fish | 1 + share/completions/funcsave.fish | 1 + share/completions/gv.fish | 4 +++ share/completions/htop.fish | 5 +++ share/completions/ifdown.fish | 2 ++ share/completions/ifup.fish | 2 ++ share/completions/kill.fish | 31 ++----------------- share/completions/killall.fish | 20 ++++++++++++ share/completions/latexmk.fish | 7 +++++ share/completions/ln.fish | 18 +++++++++++ share/completions/lualatex.fish | 2 ++ share/completions/mupdf.fish | 2 ++ share/completions/nm.fish | 29 +++++++++++++++++ share/completions/sudo.fish | 10 ++++-- share/completions/wvdial.fish | 1 + share/completions/xdvi.fish | 1 + share/completions/xelatex.fish | 2 ++ share/completions/xpdf.fish | 1 + share/functions/__fish_complete_proc.fish | 4 +++ .../__fish_complete_subcommand_root.fish | 4 ++- share/functions/__fish_complete_suffix.fish | 4 +-- share/functions/__fish_complete_tex.fish | 11 +++++++ .../__fish_make_completion_signals.fish | 17 ++++++++++ 30 files changed, 175 insertions(+), 39 deletions(-) create mode 100644 share/completions/djview.fish create mode 100644 share/completions/djview3.fish create mode 100644 share/completions/djview4.fish create mode 100644 share/completions/dlocate.fish create mode 100644 share/completions/dpkg.fish create mode 100644 share/completions/funced.fish create mode 100644 share/completions/funcsave.fish create mode 100644 share/completions/gv.fish create mode 100644 share/completions/htop.fish create mode 100644 share/completions/ifdown.fish create mode 100644 share/completions/ifup.fish create mode 100644 share/completions/killall.fish create mode 100644 share/completions/latexmk.fish create mode 100644 share/completions/ln.fish create mode 100644 share/completions/lualatex.fish create mode 100644 share/completions/mupdf.fish create mode 100644 share/completions/nm.fish create mode 100644 share/completions/wvdial.fish create mode 100644 share/completions/xdvi.fish create mode 100644 share/completions/xelatex.fish create mode 100644 share/functions/__fish_complete_proc.fish create mode 100644 share/functions/__fish_make_completion_signals.fish diff --git a/share/completions/adduser.fish b/share/completions/adduser.fish index 0ce13ec80..9704625c1 100644 --- a/share/completions/adduser.fish +++ b/share/completions/adduser.fish @@ -5,7 +5,8 @@ # have been hand edited since. # -complete -c adduser -l conf --description 'Specify config file" -r +complete -x -c adduser -a "(__fish_complete_users; __fish_complete_groups)" +complete -c adduser -l conf --description 'Specify config file' -r complete -c adduser -l disabled-login --description 'Do not run passwd to set the password' complete -c adduser -l disabled-password --description 'Like --disabled-login, but logins are still possible (for example using SSH RSA keys) but not using password authentication' complete -c adduser -l force-badname --description 'By default, user and group names are checked against the configurable regular expression NAME_REGEX (or NAME_REGEX if --system is specified) specified in the configuration file' @@ -13,10 +14,10 @@ complete -c adduser -l gecos --description 'Set the gecos field for the new entr complete -c adduser -l gid --description 'When creating a group, this option forces the new groupid to be the given number' -r complete -c adduser -l group --description 'When combined with --system, a group with the same name and ID as the system user is created' complete -c adduser -l help --description 'Display brief instructions' -complete -c adduser -l home --description 'Use specified directory as the user's home directory' -x -a '(__fish_complete_directories)' -complete -c adduser -l shell --description 'Use shell as the user's login shell, rather than the default specified by the configuration file' -x -a '(cat /etc/shells)' +complete -c adduser -l home --description 'Use specified directory as the user\'s home directory' -x -a '(__fish_complete_directories)' +complete -c adduser -l shell --description 'Use shell as the user\'s login shell, rather than the default specified by the configuration file' -x -a '(cat /etc/shells)' complete -c adduser -l ingroup --description 'Add the new user to GROUP instead of a usergroup or the default group defined by USERS_GID in the configuration file' -x -a '(cat /etc/group|cut -d : -f 1)' -complete -c adduser -l no-create-home --description 'Do not create the home directory, even if it doesn't exist' +complete -c adduser -l no-create-home --description 'Do not create the home directory, even if it doesni\'t exist' complete -c adduser -l quiet --description 'Suppress informational messages, only show warnings and errors' complete -c adduser -l debug --description 'Be verbose, most useful if you want to nail down a problem with adduser' complete -c adduser -l system --description 'Create a system user or group' diff --git a/share/completions/djview.fish b/share/completions/djview.fish new file mode 100644 index 000000000..3822026b1 --- /dev/null +++ b/share/completions/djview.fish @@ -0,0 +1,3 @@ + +complete -c djview -x -a "(__fish_complete_suffix .djvu)" + diff --git a/share/completions/djview3.fish b/share/completions/djview3.fish new file mode 100644 index 000000000..961796106 --- /dev/null +++ b/share/completions/djview3.fish @@ -0,0 +1,3 @@ + +complete -c djview3 -x -a "(__fish_complete_suffix .djvu)" + diff --git a/share/completions/djview4.fish b/share/completions/djview4.fish new file mode 100644 index 000000000..ca81c3f42 --- /dev/null +++ b/share/completions/djview4.fish @@ -0,0 +1,3 @@ + +complete -c djview4 -x -a "(__fish_complete_suffix .djvu)" + diff --git a/share/completions/dlocate.fish b/share/completions/dlocate.fish new file mode 100644 index 000000000..7289bf971 --- /dev/null +++ b/share/completions/dlocate.fish @@ -0,0 +1,6 @@ + +complete -c dlocate -s S -x -d 'List records that match filenames' +complete -c dlocate -s L -d 'List all files in the package' -xa '(__fish_print_packages)' +complete -c dlocate -o ls -d 'ls -ldF all files in the package' -xa '(__fish_print_packages)' +complete -c dlocate -o du -d 'du -sck all files in the package' -xa '(__fish_print_packages)' + diff --git a/share/completions/dpkg.fish b/share/completions/dpkg.fish new file mode 100644 index 000000000..c199bdada --- /dev/null +++ b/share/completions/dpkg.fish @@ -0,0 +1,6 @@ + +complete -c dpkg -s i -l install -d 'Install .deb package' -xa '(__fish_complete_suffix .deb)' +complete -c dpkg -s r -l remove -d 'Remove package' -xa '(__fish_print_packages)' +complete -c dpkg -s P -l purge -d 'Purge package' -xa '(__fish_print_packages)' +complete -c dpkg -l force-all -d 'Continue on all problems' + diff --git a/share/completions/find.fish b/share/completions/find.fish index eba8392b3..87bdedace 100644 --- a/share/completions/find.fish +++ b/share/completions/find.fish @@ -36,8 +36,9 @@ complete -c find -o cmin --description "File status last changed specified numbe complete -c find -o cnewer --description "File status last changed more recently than file was modified" -r complete -c find -o ctime --description "File status last changed specified number of days ago" -r -complete -c find -o empty --description "File is empty and is either a regular file or a directory" -complete -c find -o false --description "Always false" +complete -c find -o empty --description "File is empty and is either a regular file or a directory" +complete -c find -o executable --description "File is executable" +complete -c find -o false --description "Always false" complete -c find -o fstype --description "File is on filesystem of specified type" -a "(__fish_print_filesystems)" -r complete -c find -o gid --description "Numeric group id of file" -r complete -c find -o group --description "Group name of file" -a "(__fish_complete_groups)" diff --git a/share/completions/funced.fish b/share/completions/funced.fish new file mode 100644 index 000000000..2e9f66a4e --- /dev/null +++ b/share/completions/funced.fish @@ -0,0 +1 @@ +complete -c funced -xa "(functions -na)" --description "Save function" diff --git a/share/completions/funcsave.fish b/share/completions/funcsave.fish new file mode 100644 index 000000000..26f76d411 --- /dev/null +++ b/share/completions/funcsave.fish @@ -0,0 +1 @@ +complete -c funcsave -xa "(functions -na)" --description "Save function" diff --git a/share/completions/gv.fish b/share/completions/gv.fish new file mode 100644 index 000000000..6b20e3806 --- /dev/null +++ b/share/completions/gv.fish @@ -0,0 +1,4 @@ +complete -c gv -x -a "(__fish_complete_suffix .ps)" +complete -c gv -x -a "(__fish_complete_suffix .ps.gz)" +complete -c gv -x -a "(__fish_complete_suffix .eps)" +complete -c gv -x -a "(__fish_complete_suffix .pdf)" diff --git a/share/completions/htop.fish b/share/completions/htop.fish new file mode 100644 index 000000000..c4894a9de --- /dev/null +++ b/share/completions/htop.fish @@ -0,0 +1,5 @@ +# Completions for top +complete -c htop -s d --description "Update interval" -x +complete -c htop -s u --description "Monitor effective UID" -x -a "(__fish_complete_users)" +complete -c htop -l sort-key -d 'Sort column' -xa "(htop --sort-key '')" + diff --git a/share/completions/ifdown.fish b/share/completions/ifdown.fish new file mode 100644 index 000000000..227672fa8 --- /dev/null +++ b/share/completions/ifdown.fish @@ -0,0 +1,2 @@ +complete -x -c ifdown -a "(__fish_print_interfaces)" --description "Network interface" +complete -c ifdown -l force --description "force" diff --git a/share/completions/ifup.fish b/share/completions/ifup.fish new file mode 100644 index 000000000..0197867be --- /dev/null +++ b/share/completions/ifup.fish @@ -0,0 +1,2 @@ +complete -x -c ifup -a "(__fish_print_interfaces)" --description "Network interface" +complete -c ifup -l force --description "force" diff --git a/share/completions/kill.fish b/share/completions/kill.fish index 724effa6d..cd7d2353a 100644 --- a/share/completions/kill.fish +++ b/share/completions/kill.fish @@ -1,38 +1,13 @@ -# Completions for the kill command +__fish_make_completion_signals -set -l signals - -if kill -L ^/dev/null >/dev/null - - # Debian and some related systems use 'kill -L' to write out a numbered list - # of signals. Use this to complete on both number _and_ on signal name. - - complete -c kill -s L --description "List codes and names of available signals" - - set signals (kill -L | sed -e 's/\([0-9][0-9]*\) *\([A-Z,0-9][A-Z,0-9]*\)/\1 \2\n/g;s/ +/ /g' | sed -e 's/^ //' | sgrep -E '^[^ ]+') - -else - - # Posix systems print out the name of a signal using 'kill -l - # SIGNUM', so we use this instead. - - complete -c kill -s l --description "List names of available signals" - - for i in (seq 31) - set signals $signals $i" "(kill -l $i) - end - -end - -for i in $signals +for i in $__kill_signals set number (echo $i | cut -d " " -f 1) set name (echo $i | cut -d " " -f 2) complete -c kill -o $number -d $name complete -c kill -o $name -d $name complete -c kill -o s -x -a \"$number\tSend\ $name\ signal\" - complete -c kill -o s -x -a \"$name\tSend\ $name\ signal\" + complete -c kill -o s -x -a \"$name\tSend\ $name\ signal\" end - complete -c kill -xa '(__fish_complete_pids)' diff --git a/share/completions/killall.fish b/share/completions/killall.fish new file mode 100644 index 000000000..dc5fec39c --- /dev/null +++ b/share/completions/killall.fish @@ -0,0 +1,20 @@ +__fish_make_completion_signals + +for i in $__kill_signals + set number (echo $i | cut -d " " -f 1) + set name (echo $i | cut -d " " -f 2) + complete -c killall -o $number -d $name + complete -c killall -o $name -d $name + complete -c killall -o s -x -a \"$number\tSend\ $name\ signal\" + complete -c killall -o s -x -a \"$name\tSend\ $name\ signal\" +end + +complete -c killall -xa '(__fish_complete_proc)' +complete -c killall -s e -l exact -d 'Require an exact match for very long names' +complete -c killall -s I -l ignore-case -d 'Do case insensitive process name match' +complete -c killall -s g -l process-group -d 'Kill the process group to which the process belongs. The kill signal is only sent once per group, even if multiple processes belonging to the same process group were found' +complete -c killall -s i -l interactive -d 'Interactively ask for confirmation before killing' +complete -c killall -s u -l user -d 'Kill only processes the specified user owns. Command names are optional' +complete -c killall -s w -l wait -d 'Wait for all killed processes to die. killall checks once per second if any of the killed processes still exist and only returns if none are left. Note that killall may wait forever if the signal was ignored, had no effect, or if the process stays in zombie state' + + diff --git a/share/completions/latexmk.fish b/share/completions/latexmk.fish new file mode 100644 index 000000000..e5a244ac5 --- /dev/null +++ b/share/completions/latexmk.fish @@ -0,0 +1,7 @@ +complete -c latexmk -x -a "(__fish_complete_suffix (commandline -ct) .tex '(La)TeX file')" +complete -c latexmk -o dvi -d "Make dvi" +complete -c latexmk -o ps -d "Make ps dvi->ps" +complete -c latexmk -o pdf -d "Make pdf" +complete -c latexmk -o pdfps -d "Make pdf dvi->ps->pdf" +complete -c latexmk -o pdfdvi -d "Make pdf dvi->pdf" + diff --git a/share/completions/ln.fish b/share/completions/ln.fish new file mode 100644 index 000000000..d1d0fc029 --- /dev/null +++ b/share/completions/ln.fish @@ -0,0 +1,18 @@ +# completions for ln +# Author: SanskritFritz (gmail) + +complete -c ln -f -s s -l symbolic -d 'make symbolic links instead of hard links' +complete -c ln -f -l backup=CONTROL -d 'make a backup of each existing destination file' +complete -c ln -f -s b -d 'like --backup but does not accept an argument' +complete -c ln -f -s d -l directory -d 'allow the superuser to attempt to hard link directories' +complete -c ln -f -s f -l force -d 'remove existing destination files' +complete -c ln -f -s i -l interactive -d 'prompt whether to remove destinations' +complete -c ln -f -s L -l logical -d 'make hard links to symbolic link references' +complete -c ln -f -s n -l no-dereference -d 'treat destination that is a symlink to a directory as if it were a normal file' +complete -c ln -f -s P -l physical -d 'make hard links directly to symbolic links' +complete -c ln -f -s S -l suffix=SUFFIX -d 'override the usual backup suffix' +complete -c ln -f -s t -l target-directory=DIRECTORY -d 'specify the DIRECTORY in which to create the links' +complete -c ln -f -s T -l no-target-directory -d 'treat LINK_NAME as a normal file' +complete -c ln -f -s v -l verbose -d 'print name of each linked file' +complete -c ln -f -l help -d 'display this help and exit' +complete -c ln -f -l version -d 'output version information and exit' diff --git a/share/completions/lualatex.fish b/share/completions/lualatex.fish new file mode 100644 index 000000000..2aa472eff --- /dev/null +++ b/share/completions/lualatex.fish @@ -0,0 +1,2 @@ +__fish_complete_tex lualatex + diff --git a/share/completions/mupdf.fish b/share/completions/mupdf.fish new file mode 100644 index 000000000..4ba874924 --- /dev/null +++ b/share/completions/mupdf.fish @@ -0,0 +1,2 @@ +complete -c mupdf -x -a "(__fish_complete_suffix .pdf)" + diff --git a/share/completions/nm.fish b/share/completions/nm.fish new file mode 100644 index 000000000..832d31925 --- /dev/null +++ b/share/completions/nm.fish @@ -0,0 +1,29 @@ +complete -c nm -s a -l debug-syms -d 'Display debugger-only symbols' +complete -c nm -s A -l print-file-name -d 'Print name of the input file before every symbol' +#complete -c nm -C -l demangle[=STYLE] Decode low-level symbol names into user-level names +# Same as --format=bsd +# The STYLE, if specified, can be `auto' (the default), +# `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java' or `gnat' +complete -c nm -l no-demangle -d 'Do not demangle low-level symbol names' +complete -c nm -s D -l dynamic -d 'Display dynamic symbols instead of normal symbols' +complete -c nm -l defined-only -d 'Display only defined symbols' +complete -c nm -s f -l format=FORMAT -d 'Use the output format FORMAT. FORMAT can be "bsd", "sysv" or "posix". The default is "bsd"' +complete -c nm -s g -l extern-only -d 'Display only external symbols' +complete -c nm -s l -l line-numbers -d 'Use debugging information to find a filename and line number for each symbol' +complete -c nm -s n -l numeric-sort -d 'Sort symbols numerically by address' +complete -c nm -s o -d 'Print name of the input file before every symbol' +complete -c nm -s p -l no-sort -d 'Do not sort the symbols' +complete -c nm -s P -l portability -d 'Same as --format=posix' +complete -c nm -s r -l reverse-sort -d 'Reverse the sense of the sort' +complete -c nm -l plugin -d 'Load the specified plugin' +complete -c nm -s S -l print-size -d 'Print size of defined symbols' +complete -c nm -s s -l print-armap -d 'Include index for symbols from archive members' +complete -c nm -l size-sort -d 'Sort symbols by size' +complete -c nm -l special-syms -d 'Include special symbols in the output' +complete -c nm -l synthetic -d 'Display synthetic symbols as well' +complete -c nm -s t -l radix=RADIX -d 'Use RADIX for printing symbol values' +complete -c nm -l target=BFDNAME -d 'Specify the target object format as BFDNAME' +complete -c nm -s u -l undefined-only -d 'Display only undefined symbols' +complete -c nm -s h -l help -d 'Display this information' +complete -c nm -s V -l version -d "Display this program's version number" + diff --git a/share/completions/sudo.fish b/share/completions/sudo.fish index b9e4faaf5..c7e24cd08 100644 --- a/share/completions/sudo.fish +++ b/share/completions/sudo.fish @@ -2,10 +2,16 @@ # Completion for sudo # -complete -c sudo --description "Command to run" -x -a '(__fish_complete_subcommand_root)' - complete -c sudo -s h -n "__fish_no_arguments" --description "Display help and exit" complete -c sudo -s v -n "__fish_no_arguments" --description "Validate" +complete -c sudo -s u -a "(__fish_complete_users)" -x -d "Run command as user" +complete -c sudo -s g -a "(__fish_complete_groups)" -x -d "Run command as group" +complete -c sudo -s E -d "Preserve environment" +complete -c sudo -s P -d "Preserve group vector" +complete -c sudo -s S -d "Read password from stdin" +complete -c sudo -s H -d "Set home" +complete -c sudo -s e -r -d "Edit" +complete -c sudo --description "Command to run" -x -a "(__fish_complete_subcommand_root -u -g)" # Since sudo runs subcommands, it can accept any switches complete -c sudo -u diff --git a/share/completions/wvdial.fish b/share/completions/wvdial.fish new file mode 100644 index 000000000..c850a5643 --- /dev/null +++ b/share/completions/wvdial.fish @@ -0,0 +1 @@ +complete -x -c wvdial -a "(print_wvdial)" --description "wvdial connections" diff --git a/share/completions/xdvi.fish b/share/completions/xdvi.fish new file mode 100644 index 000000000..28f4b3323 --- /dev/null +++ b/share/completions/xdvi.fish @@ -0,0 +1 @@ +complete -c xdvi -x -a "(__fish_complete_suffix .dvi)" diff --git a/share/completions/xelatex.fish b/share/completions/xelatex.fish new file mode 100644 index 000000000..400c36b72 --- /dev/null +++ b/share/completions/xelatex.fish @@ -0,0 +1,2 @@ +__fish_complete_tex xelatex + diff --git a/share/completions/xpdf.fish b/share/completions/xpdf.fish index 99d4aa46c..7ac7a4982 100644 --- a/share/completions/xpdf.fish +++ b/share/completions/xpdf.fish @@ -2,6 +2,7 @@ # Completions for the xpdf command # Vikas Gorur # +complete -c xpdf -x -a "(__fish_complete_suffix .pdf)" complete -c xpdf -s g --description "Set the initial window geometry" complete -c xpdf -o title --description "Set the window title" diff --git a/share/functions/__fish_complete_proc.fish b/share/functions/__fish_complete_proc.fish new file mode 100644 index 000000000..9d9fa6fbc --- /dev/null +++ b/share/functions/__fish_complete_proc.fish @@ -0,0 +1,4 @@ +function __fish_complete_proc --description 'Complete by list of running processes' + ps a --no-headers --format comm | uniq + +end diff --git a/share/functions/__fish_complete_subcommand_root.fish b/share/functions/__fish_complete_subcommand_root.fish index b6b2152e5..8a753709d 100644 --- a/share/functions/__fish_complete_subcommand_root.fish +++ b/share/functions/__fish_complete_subcommand_root.fish @@ -3,6 +3,8 @@ function __fish_complete_subcommand_root -d "Run the __fish_complete_subcommand function using a PATH containing /sbin and /usr/sbin" set -l PATH_OLD $PATH set PATH /sbin /usr/sbin $PATH - __fish_complete_subcommand + __fish_complete_subcommand $argv set PATH $PATH_OLD + + end diff --git a/share/functions/__fish_complete_suffix.fish b/share/functions/__fish_complete_suffix.fish index 5abdb2ffd..1f3207063 100644 --- a/share/functions/__fish_complete_suffix.fish +++ b/share/functions/__fish_complete_suffix.fish @@ -26,10 +26,10 @@ function __fish_complete_suffix -d "Complete using files" set suff $argv[2] set desc (mimedb -d $suff) - case 2 + case 3 set comp $argv[1] set suff $argv[2] - set desc $argv[2] + set desc $argv[3] end diff --git a/share/functions/__fish_complete_tex.fish b/share/functions/__fish_complete_tex.fish index 637b74641..1c8876feb 100644 --- a/share/functions/__fish_complete_tex.fish +++ b/share/functions/__fish_complete_tex.fish @@ -7,4 +7,15 @@ function __fish_complete_tex -d "Common completions for all tex commands" __fish_complete_suffix (commandline -ct) .tex '(La)TeX file' )" + complete -c $argv -o file-line-error -d "Show errors in style file:line" + complete -c $argv -o no-file-line-error -d "Show errors not in style file:line" + complete -c $argv -o halt-on-error -d "Stop processing at the first error" + complete -c $argv -o interaction=batchmode -d "Set interation mode" + complete -c $argv -o interaction=nonstopmode -d "Set interation mode" + complete -c $argv -o interaction=scrollmode -d "Set interation mode" + complete -c $argv -o interaction=errorstopmode -d "Set interation mode" + complete -c $argv -o output-directory= -x -a "(__fish_complete_directories (commandline -ct))" -d "Output directory" + complete -c $argv -o shell-escape -d "Enable \write18{SHELL COMMAND}" + complete -c $argv -o no-shell-escape -d "Disable \write18{SHELL COMMAND}" + complete -c $argv -o src-specials -d "Insert source specials into the DVI file" end diff --git a/share/functions/__fish_make_completion_signals.fish b/share/functions/__fish_make_completion_signals.fish new file mode 100644 index 000000000..a8d978192 --- /dev/null +++ b/share/functions/__fish_make_completion_signals.fish @@ -0,0 +1,17 @@ +function __fish_make_completion_signals --description 'Make list of kill signals for copmletion' + set -q __kill_signals; and return 0 + + if kill -L ^/dev/null >/dev/null + # Debian and some related systems use 'kill -L' to write out a numbered list + # of signals. Use this to complete on both number _and_ on signal name. + complete -c kill -s L --description "List codes and names of available signals" + set -g __kill_signals (kill -L | sed -e 's/\([0-9][0-9]*\) *\([A-Z,0-9][A-Z,0-9]*\)/\1 \2\n/g;s/ +/ /g' | sed -e 's/^ \+//' | sgrep -E '^[^ ]+') + else + # Posix systems print out the name of a signal using 'kill -l + # SIGNUM', so we use this instead. + complete -c kill -s l --description "List names of available signals" + for i in (seq 31) + set -g __kill_signals $signals $i" "(kill -l $i) + end + end +end From 39a2fd1717dc69b9f4643bb6a2060713c2e5f636 Mon Sep 17 00:00:00 2001 From: gonchar Date: Fri, 23 Sep 2011 14:51:14 +0400 Subject: [PATCH 2/7] * git rm and git status options are added * ssh subcomand completion * __fish_complete_subcommand now can skip variable number of tokens --- share/completions/git.fish | 15 ++++++++++++++- share/completions/ssh.fish | 5 ++++- share/functions/__fish_complete_subcommand.fish | 16 +++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index 6350513ae..df6d045dc 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -196,11 +196,24 @@ complete -f -c git -n '__fish_git_needs_command' -a revert -d 'Revert an existin # TODO options ### rm -complete -c git -n '__fish_git_needs_command' -a rm -d 'Remove files from the working tree and from the index' +complete -c git -n '__fish_git_needs_command' -a rm -d 'Remove files from the working tree and from the index' +complete -c git -n '__fish_git_using_command rm' -f +complete -c git -n '__fish_git_using_command rm' -l cached -d 'Keep local copies' +complete -c git -n '__fish_git_using_command rm' -l ignore-unmatch -d 'Exit with a zero status even if no files matched' +complete -c git -n '__fish_git_using_command rm' -s r -d 'Allow recursive removal' +complete -c git -n '__fish_git_using_command rm' -s q -l quiet -d 'Suppress the output' +complete -c git -n '__fish_git_using_command rm' -s f -l force -d 'Override the up-to-date check' +complete -c git -n '__fish_git_using_command rm' -s n -l dry-run -d 'Dry run' # TODO options ### status complete -f -c git -n '__fish_git_needs_command' -a status -d 'Show the working tree status' +complete -f -c git -n '__fish_git_using_command status' -s s -l short -d 'Give the output in the short-format' +complete -f -c git -n '__fish_git_using_command status' -s b -l branch -d 'Show the branch and tracking info even in short-format' +complete -f -c git -n '__fish_git_using_command status' -l porcelain -d 'Give the output in a stable, easy-to-parse format' +complete -f -c git -n '__fish_git_using_command status' -s z -d 'Terminate entries with NUL character' +complete -f -c git -n '__fish_git_using_command status' -s u -l untracked-files -x -a 'no normal all' -d 'The untracked files handling mode' +complete -f -c git -n '__fish_git_using_command status' -l ignore-submodules -x -a 'none untracked dirty all' -d 'Ignore changes to submodules' # TODO options ### tag diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish index 5cbaacfff..aada35e01 100644 --- a/share/completions/ssh.fish +++ b/share/completions/ssh.fish @@ -15,9 +15,9 @@ complete -x -c ssh -d Hostname -a " " complete -x -c ssh -d User -a " - (__fish_print_users)@ " +complete -c ssh --description "Command to run" -x -a '(__fish_complete_subcommand --fcs-skip=2)' complete -c ssh -s a --description "Disables forwarding of the authentication agent" complete -c ssh -s A --description "Enables forwarding of the authentication agent" @@ -46,3 +46,6 @@ complete -c ssh -s X --description "Enable X11 forwarding" complete -c ssh -s L --description "Locally forwarded ports" complete -c ssh -s R --description "Remotely forwarded ports" complete -c ssh -s D --description "Dynamic port forwarding" + +# Since ssh runs subcommands, it can accept any switches +complete -c ssh -u diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index c002b8123..885b05442 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -1,14 +1,20 @@ function __fish_complete_subcommand -d "Complete subcommand" + set -l skip_next 1 + switch "$argv[1]" + case '--fcs-skip=*' + set -l rest + echo $argv[1] | tr = ' ' | read test skip_next + set -e argv[1] + end set -l res "" set -l had_cmd 0 set -l cmd (commandline -cop) (commandline -ct) - set -l skip_next 1 for i in $cmd - if test "$skip_next" = 1 - set skip_next 0 + if test $skip_next -gt 0 + set skip_next (expr $skip_next - 1) continue end @@ -17,15 +23,15 @@ function __fish_complete_subcommand -d "Complete subcommand" else if contains -- $i $argv - set skip_next 1 + set skip_next (expr $skip_next + 1) continue end switch $i case '-*' case '*=*' - case '*' + set had_cmd 1 set res $i end From 7ef0b3b821c507f3bec27430e731e0e371e02206 Mon Sep 17 00:00:00 2001 From: gonchar Date: Fri, 23 Sep 2011 18:40:14 +0400 Subject: [PATCH 3/7] *wvdial completion fixed --- share/completions/wvdial.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/completions/wvdial.fish b/share/completions/wvdial.fish index c850a5643..eb7320ca3 100644 --- a/share/completions/wvdial.fish +++ b/share/completions/wvdial.fish @@ -1 +1 @@ -complete -x -c wvdial -a "(print_wvdial)" --description "wvdial connections" +complete -x -c wvdial -a "(cat ~/.wvdialrc | grep '\[Dialer' | sed 's/\[Dialer \(.\+\)\]/\1/')" --description "wvdial connections" From a060cc5893d09404f3aadfe40fd2d579d118b7eb Mon Sep 17 00:00:00 2001 From: Jan Kanis Date: Fri, 23 Sep 2011 21:59:50 +0200 Subject: [PATCH 4/7] uniq doesn't filter duplicates that aren't consecutive, use sort -u --- share/functions/__fish_complete_proc.fish | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/functions/__fish_complete_proc.fish b/share/functions/__fish_complete_proc.fish index 9d9fa6fbc..84e3bd9d4 100644 --- a/share/functions/__fish_complete_proc.fish +++ b/share/functions/__fish_complete_proc.fish @@ -1,4 +1,3 @@ function __fish_complete_proc --description 'Complete by list of running processes' - ps a --no-headers --format comm | uniq - + ps a --no-headers --format comm | sort -u end From 548164cd5e7888c772ac2284d20dbe5cb9518332 Mon Sep 17 00:00:00 2001 From: Jan Kanis Date: Tue, 24 Jan 2012 18:39:47 +0100 Subject: [PATCH 5/7] do not escape 'commandline' output without the -o flag --- CHANGELOG | 3 +++ builtin_commandline.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 CHANGELOG diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 000000000..da7b35942 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,3 @@ +24-01-2012 Jan Kanis + * Added a changelog file + * removed unescaping if the 'commandline' builtin is called without the -o (tokenise) flag diff --git a/builtin_commandline.c b/builtin_commandline.c index f23e1153f..ddcba6ac8 100644 --- a/builtin_commandline.c +++ b/builtin_commandline.c @@ -188,7 +188,7 @@ static void write_part( const wchar_t *begin, } else { - wchar_t *buff, *esc; + wchar_t *buff; if( cut_at_cursor ) { @@ -196,14 +196,12 @@ static void write_part( const wchar_t *begin, } buff = wcsndup( begin, end-begin ); - esc = unescape( buff, UNESCAPE_INCOMPLETE ); // debug( 0, L"woot2 %ls -> %ls", buff, esc ); - sb_append( sb_out, esc ); + sb_append( sb_out, buff ); sb_append( sb_out, L"\n" ); - free( esc ); free( buff ); } From b0c6d891e967267468ac59befa60e9844be3d949 Mon Sep 17 00:00:00 2001 From: Jan Kanis Date: Wed, 25 Jan 2012 01:14:47 +0100 Subject: [PATCH 6/7] reviewed merge reqest 14: * fixed some whitespace inconsistencies * changed variable handling in __fish_complete_subcommand_root --- .../functions/__fish_complete_subcommand.fish | 18 +++++++-------- .../__fish_complete_subcommand_root.fish | 6 +---- share/functions/__fish_complete_tex.fish | 22 +++++++++---------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index 885b05442..c71f3fea5 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -1,11 +1,11 @@ -function __fish_complete_subcommand -d "Complete subcommand" +function __fish_complete_subcommand -d "Complete subcommand" set -l skip_next 1 - switch "$argv[1]" - case '--fcs-skip=*' - set -l rest - echo $argv[1] | tr = ' ' | read test skip_next - set -e argv[1] - end + switch "$argv[1]" + case '--fcs-skip=*' + set -l rest + echo $argv[1] | tr = ' ' | read test skip_next + set -e argv[1] + end set -l res "" set -l had_cmd 0 @@ -14,7 +14,7 @@ function __fish_complete_subcommand -d "Complete subcommand" for i in $cmd if test $skip_next -gt 0 - set skip_next (expr $skip_next - 1) + set skip_next (expr $skip_next - 1) continue end @@ -31,7 +31,7 @@ function __fish_complete_subcommand -d "Complete subcommand" case '-*' case '*=*' case '*' - + set had_cmd 1 set res $i end diff --git a/share/functions/__fish_complete_subcommand_root.fish b/share/functions/__fish_complete_subcommand_root.fish index 8a753709d..f4df8d9d3 100644 --- a/share/functions/__fish_complete_subcommand_root.fish +++ b/share/functions/__fish_complete_subcommand_root.fish @@ -1,10 +1,6 @@ function __fish_complete_subcommand_root -d "Run the __fish_complete_subcommand function using a PATH containing /sbin and /usr/sbin" - set -l PATH_OLD $PATH - set PATH /sbin /usr/sbin $PATH + set -lx PATH /sbin /usr/sbin $PATH __fish_complete_subcommand $argv - set PATH $PATH_OLD - - end diff --git a/share/functions/__fish_complete_tex.fish b/share/functions/__fish_complete_tex.fish index 1c8876feb..ecff08714 100644 --- a/share/functions/__fish_complete_tex.fish +++ b/share/functions/__fish_complete_tex.fish @@ -7,15 +7,15 @@ function __fish_complete_tex -d "Common completions for all tex commands" __fish_complete_suffix (commandline -ct) .tex '(La)TeX file' )" - complete -c $argv -o file-line-error -d "Show errors in style file:line" - complete -c $argv -o no-file-line-error -d "Show errors not in style file:line" - complete -c $argv -o halt-on-error -d "Stop processing at the first error" - complete -c $argv -o interaction=batchmode -d "Set interation mode" - complete -c $argv -o interaction=nonstopmode -d "Set interation mode" - complete -c $argv -o interaction=scrollmode -d "Set interation mode" - complete -c $argv -o interaction=errorstopmode -d "Set interation mode" - complete -c $argv -o output-directory= -x -a "(__fish_complete_directories (commandline -ct))" -d "Output directory" - complete -c $argv -o shell-escape -d "Enable \write18{SHELL COMMAND}" - complete -c $argv -o no-shell-escape -d "Disable \write18{SHELL COMMAND}" - complete -c $argv -o src-specials -d "Insert source specials into the DVI file" + complete -c $argv -o file-line-error -d "Show errors in style file:line" + complete -c $argv -o no-file-line-error -d "Show errors not in style file:line" + complete -c $argv -o halt-on-error -d "Stop processing at the first error" + complete -c $argv -o interaction=batchmode -d "Set interation mode" + complete -c $argv -o interaction=nonstopmode -d "Set interation mode" + complete -c $argv -o interaction=scrollmode -d "Set interation mode" + complete -c $argv -o interaction=errorstopmode -d "Set interation mode" + complete -c $argv -o output-directory= -x -a "(__fish_complete_directories (commandline -ct))" -d "Output directory" + complete -c $argv -o shell-escape -d "Enable \write18{SHELL COMMAND}" + complete -c $argv -o no-shell-escape -d "Disable \write18{SHELL COMMAND}" + complete -c $argv -o src-specials -d "Insert source specials into the DVI file" end From 23bc10dfe6153112f1d630854aec75fc17798080 Mon Sep 17 00:00:00 2001 From: Jan Kanis Date: Tue, 31 Jan 2012 01:38:20 +0100 Subject: [PATCH 7/7] Add stddef.h to util.c, so ptrdiff_t is defined in all environments --- util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util.c b/util.c index f611c5ef8..e9a2bee0d 100644 --- a/util.c +++ b/util.c @@ -7,6 +7,7 @@ #include "config.h" +#include #include #include #include