From 06932d52c9a9542d00e58abe1d647716a5149c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 11 Feb 2009 00:07:08 +0200 Subject: Clean up killall sed scripts. --- bash_completion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash_completion b/bash_completion index 9283e23b..c2d8be1d 100644 --- a/bash_completion +++ b/bash_completion @@ -1013,8 +1013,8 @@ _killall() _signals else COMPREPLY=( $( compgen -W '$( command ps axo command | \ - sed -e "1d; s/ .*//g; s:^/.*/::g; s/:$//g;" \ - -e "s/^-//g; s/^\[//g; s/\]$//g; s:/.*::g")' \ + sed -e "1d; s/ .*//; s:^/.*/::; s/:$//;" \ + -e "s/^[[-]//; s/\]$//; s:/.*::")' \ -- $cur ) ) fi -- cgit v1.2.1 From 47d0c5be2c1a30de898351a58d124343feb0a36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 11 Feb 2009 00:11:09 +0200 Subject: Handle parenthesis, in killall completion. --- bash_completion | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index c2d8be1d..76558961 100644 --- a/bash_completion +++ b/bash_completion @@ -1014,7 +1014,8 @@ _killall() else COMPREPLY=( $( compgen -W '$( command ps axo command | \ sed -e "1d; s/ .*//; s:^/.*/::; s/:$//;" \ - -e "s/^[[-]//; s/\]$//; s:/.*::")' \ + -e "s/^[[(-]//; s/[])]$//; s:/.*::" \ + -e "s/^$//")' \ -- $cur ) ) fi -- cgit v1.2.1 From 9e08218fb933f4fea858da5928ccc7978603250a Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Tue, 10 Feb 2009 23:39:10 +0100 Subject: make perl completion a bit more consistant with other, by first dealing with options, then with main arguments --- bash_completion | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/bash_completion b/bash_completion index 76558961..0a5d75fe 100644 --- a/bash_completion +++ b/bash_completion @@ -5361,16 +5361,12 @@ _perl() ;; esac - # handle case where first parameter is not a dash option - if [[ "`_get_cword`" != -* ]]; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d \ + -D -p -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) ) + else _filedir - return 0 fi - - # complete using basic options - COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \ - -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) ) - return 0 } complete -F _perl $nospace $filenames perl @@ -5427,21 +5423,15 @@ _perldoc() ;; esac - case $cur in - -*) + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur )) - return 0 - ;; - */*) - return 0 - ;; - *) - _perlmodules - COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=/bin/cat man perl | sed -ne "/perl.*Perl overview/,/perlwin32/p" | awk "\$NF=2 { print \$1}" | grep perl )' -- $cur ) ) - - return 0 - ;; - esac + else + # return available modules (unless it is clearly a file) + if [[ "$cur" != */* ]]; then + _perlmodules + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=/bin/cat man perl | sed -ne "/perl.*Perl overview/,/perlwin32/p" | awk "\$NF=2 { print \$1}" | grep perl )' -- $cur ) ) + fi + fi } complete -F _perldoc $default perldoc } -- cgit v1.2.1 From 935295c28044e330f946adc368f437692b6e78f8 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Tue, 10 Feb 2009 23:50:04 +0100 Subject: new helper functions: - _usb_ids completes on USB ids - _pci_ids completes on PCI ids --- bash_completion | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bash_completion b/bash_completion index 0a5d75fe..346091fa 100644 --- a/bash_completion +++ b/bash_completion @@ -522,6 +522,22 @@ _count_args() done } +# This function complete on PCI IDs +# +_pci_ids() +{ + COMPREPLY=( ${COMPREPLY[@]:-} \ + $( compgen -W "$( lspci -n | awk '{print $3}')" -- $cur ) ) +} + +# This function complete on USB IDs +# +_usb_ids() +{ + COMPREPLY=( ${COMPREPLY[@]:-} \ + $( compgen -W "$( lsusb | awk '{print $6}')" -- $cur ) ) +} + # start of section containing completion functions for bash built-ins # bash alias completion -- cgit v1.2.1 From 6c27cd16ddf9353d02f6385da21505e1b2e10604 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Thu, 12 Feb 2009 22:12:20 +0100 Subject: - split _command function in two different functions: _command now only computes where wrapped command start _command_offset actually takes care of running wrapped command completion - drop _remove_comp_word function, as context rewriting is now performed more efficiently in _command_offset - drop strace minimal completion, there is a better dedicated completion waiting review --- bash_completion | 98 +++++++++++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/bash_completion b/bash_completion index 346091fa..bd9e3585 100644 --- a/bash_completion +++ b/bash_completion @@ -3189,35 +3189,20 @@ else complete -F _cd $nospace cd fi -_remove_comp_word() -{ - if [[ COMP_CWORD -eq 0 ]]; then - return - elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then - local old_cw0="${COMP_WORDS[0]}" - local new_cw0="${COMP_WORDS[1]}" - local old_length="${#COMP_LINE}" - COMP_LINE=${COMP_LINE#${old_cw0}} - local head=${COMP_LINE:0:${#new_cw0}} - local i=1 - while [[ $head != $new_cw0 ]]; do - COMP_LINE=${COMP_LINE:1} - head=${COMP_LINE:0:${#new_cw0}} - if (( ++i > 10 )); then - break - fi - done - local new_length="${#COMP_LINE}" - COMP_POINT=$(( COMP_POINT + new_length - old_length )) - - COMP_CWORD=$(( COMP_CWORD - 1 )) - for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do - COMP_WORDS[i]="${COMP_WORDS[i+1]}" - done - unset COMP_WORDS[${#COMP_WORDS[@]}-1] - else - return - fi +# a wrapper method for the next one, when the offset is unknown +_command() +{ + local offset i + + # find actual offset, as position of the first non-option + offset=1 + for (( i=1; i <= COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" != -* ]]; then + offset=$i + break + fi + done + _command_offset $offset } # A meta-command completion function for commands like sudo(8), which need to @@ -3225,38 +3210,48 @@ _remove_comp_word() # completion definition - currently not quite foolproof (e.g. mount and umount # don't work properly), but still quite useful. # -_command() +_command_offset() { - local cur func cline cspec noglob cmd done i \ + local cur func cline cspec noglob cmd i char_offset word_offset \ _COMMAND_FUNC _COMMAND_FUNC_ARGS - _remove_comp_word + word_offset=$1 + + # rewrite current completion context before invoking + # actual command completion + + # find new first word position, then + # rewrite COMP_LINE and adjust COMP_POINT + local first_word=${COMP_WORDS[$word_offset]} + for (( i=0; i <= ${#COMP_LINE}; i++ )); do + if [[ "${COMP_LINE:$i:${#first_word}}" == "$first_word" ]]; then + char_offset=$i + break + fi + done + COMP_LINE=${COMP_LINE:$char_offset} + COMP_POINT=$(( COMP_POINT - $char_offset )) + + # shift COMP_WORDS elements and adjust COMP_CWORD + for (( i=0; i <= COMP_CWORD - $word_offset; i++ )); do + COMP_WORDS[i]=${COMP_WORDS[i+$word_offset]} + done + for (( i; i <= COMP_CWORD; i++ )); do + unset COMP_WORDS[i]; + done + COMP_CWORD=$(( $COMP_CWORD - $word_offset )) + COMPREPLY=() cur=`_get_cword` - # If the the first arguments following our meta-command-invoker are - # switches, get rid of them. Most definitely not foolproof. - done= - while [ -z $done ] ; do - cmd=${COMP_WORDS[0]} - if [[ "$cmd" == -* ]] && [[ $COMP_CWORD -ge 1 ]]; then - _remove_comp_word - elif [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then - return - else - done=1 - fi - done if [[ $COMP_CWORD -eq 0 ]]; then COMPREPLY=( $( compgen -c -- $cur ) ) - elif complete -p $cmd &>/dev/null; then + else + cmd=${COMP_WORDS[0]} + if complete -p $cmd &>/dev/null; then cspec=$( complete -p $cmd ) if [ "${cspec#* -F }" != "$cspec" ]; then # complete -F - # - # COMP_CWORD and COMP_WORDS() are not read-only, - # so we can set them before handing off to regular - # completion routine # get function name func=${cspec#*-F } @@ -3283,11 +3278,12 @@ _command() cspec=${cspec%%$cmd}; COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) ); fi + fi fi [ ${#COMPREPLY[@]} -eq 0 ] && _filedir } -complete -F _command $filenames nohup exec nice eval strace time ltrace then \ +complete -F _command $filenames nohup exec nice eval time ltrace then \ else do vsound command xargs tsocks _root_command() -- cgit v1.2.1 From ea0d17b6853980d6dd73624ad3cfa11e8a767958 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Thu, 12 Feb 2009 22:24:35 +0100 Subject: don't append = automatically after alias completion, for sake of minimal completion --- bash_completion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index bd9e3585..d5560d70 100644 --- a/bash_completion +++ b/bash_completion @@ -551,7 +551,7 @@ _alias() case "$COMP_LINE" in *[^=]) - COMPREPLY=( $( compgen -A alias -S '=' -- $cur ) ) + COMPREPLY=( $( compgen -A alias -- $cur ) ) ;; *=) COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | \ -- cgit v1.2.1 From 530e91f810546d4f14f1c0f99c7132f6a8aa0bea Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Thu, 12 Feb 2009 22:31:27 +0100 Subject: add cdrecord and mkisoft completion functions to wodim and genisoimage --- bash_completion | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash_completion b/bash_completion index d5560d70..3977b1c4 100644 --- a/bash_completion +++ b/bash_completion @@ -6325,7 +6325,7 @@ complete -F _dict $default dict rdict # cdrecord(1) completion # -have cdrecord && +(have cdrecord || have wodim) && _cdrecord() { local cur prev i generic_options track_options track_mode @@ -6398,11 +6398,11 @@ _cdrecord() fi } && -complete -F _cdrecord $filenames cdrecord +complete -F _cdrecord $filenames cdrecord wodim # mkisofs(8) completion # -have mkisofs && +(have mkisofs || have genisoimage) && _mkisofs() { local cur prev @@ -6470,7 +6470,7 @@ _mkisofs() fi } && -complete -F _mkisofs $filenames mkisofs +complete -F _mkisofs $filenames mkisofs genisoimage # mc(1) completion # -- cgit v1.2.1 From 42908b9d8fe546d0a70cd1914dcff1c2e3253cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 13 Feb 2009 00:03:08 +0200 Subject: Comment typo fix. --- contrib/brctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/brctl b/contrib/brctl index 6fd7b6e5..1ecdc127 100644 --- a/contrib/brctl +++ b/contrib/brctl @@ -1,7 +1,7 @@ # -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- # ex: ts=8 sw=8 noet filetype=sh # -# bash completion for brtcl +# bash completion for brctl have brctl && _brctl() -- cgit v1.2.1 From 5894a9cf76be6be7320e2d6e20a48078195fce4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 14 Feb 2009 12:43:45 +0200 Subject: Remove executable flag (the script is sourced, not executed). --- bash_completion.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 bash_completion.sh diff --git a/bash_completion.sh b/bash_completion.sh old mode 100755 new mode 100644 -- cgit v1.2.1 From 645aac47909cfbd8e10a27a9cbcbacb13731a3a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 11:45:07 +0200 Subject: Fix killall completion for commands with relative paths (RHBZ: #484578), add a FIXME. --- bash_completion | 10 ++++++++-- debian/changelog | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bash_completion b/bash_completion index 3977b1c4..b03d79fc 100644 --- a/bash_completion +++ b/bash_completion @@ -1028,9 +1028,15 @@ _killall() if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then _signals else + # FIXME: completes "[kblockd/0]" to "0". Previously it was + # completed to "kblockd" which isn't correct either. + # "kblockd/0" would be arguably most correct, but killall from + # psmisc 22 treats arguments containing "/" specially unless + # -r is given so that wouldn't quite work either. Perhaps it'd + # be best to not complete these to anything for now. COMPREPLY=( $( compgen -W '$( command ps axo command | \ - sed -e "1d; s/ .*//; s:^/.*/::; s/:$//;" \ - -e "s/^[[(-]//; s/[])]$//; s:/.*::" \ + sed -e "1d; s/ .*//; s:.*/::; s/:$//;" \ + -e "s/^[[(-]//; s/[])]$//" \ -e "s/^$//")' \ -- $cur ) ) fi diff --git a/debian/changelog b/debian/changelog index a7142f58..54c0644f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -122,6 +122,7 @@ bash-completion (200902xx) UNRELEASED; urgency=low * Fix awk error in "modprobe -r /" completion (Closes: #512556). * Expand ~foo to dir name more eagerly to avoid quoting issues. * Fix -sourcepath handling in javadoc packages completion. + * Fix killall completion for commands with relative paths (RHBZ: #484578). [ Freddy Vulto ] * Restored `_display()' completion for `display' by removing -- cgit v1.2.1 From c492f00705511800cee5634d241198355ff9db10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 18:47:34 +0200 Subject: Extract process name completion from _killall to _pnames, make it work for others than Linux and FreeBSD. --- bash_completion | 37 ++++++++++++++++++++++++++----------- debian/changelog | 4 +++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/bash_completion b/bash_completion index b03d79fc..e522898b 100644 --- a/bash_completion +++ b/bash_completion @@ -428,6 +428,31 @@ _pgids() COMPREPLY=( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur )) } +# This function completes on process names. +# AIX and SunOS prefer X/Open, all else should be BSD. +[ $UNAME = SunOS -o $UNAME = AIX ] && +_pnames() +{ + COMPREPLY=( $( compgen -W '$( command ps -efo comm | \ + sed -e 1d -e "s:.*/::" -e "s/^-//" \ + -e "s/^$//")' \ + -- $cur ) ) +} || +_pnames() +{ + # FIXME: completes "[kblockd/0]" to "0". Previously it was completed + # to "kblockd" which isn't correct either. "kblockd/0" would be + # arguably most correct, but killall from psmisc 22 treats arguments + # containing "/" specially unless -r is given so that wouldn't quite + # work either. Perhaps it'd be best to not complete these to anything + # for now. + COMPREPLY=( $( compgen -W '$( command ps axo command | \ + sed -e "1d; s/ .*//; s:.*/::; s/:$//;" \ + -e "s/^[[(-]//; s/[])]$//" \ + -e "s/^$//")' \ + -- $cur ) ) +} + # This function completes on user IDs # _uids() @@ -1028,17 +1053,7 @@ _killall() if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then _signals else - # FIXME: completes "[kblockd/0]" to "0". Previously it was - # completed to "kblockd" which isn't correct either. - # "kblockd/0" would be arguably most correct, but killall from - # psmisc 22 treats arguments containing "/" specially unless - # -r is given so that wouldn't quite work either. Perhaps it'd - # be best to not complete these to anything for now. - COMPREPLY=( $( compgen -W '$( command ps axo command | \ - sed -e "1d; s/ .*//; s:.*/::; s/:$//;" \ - -e "s/^[[(-]//; s/[])]$//" \ - -e "s/^$//")' \ - -- $cur ) ) + _pnames fi return 0 diff --git a/debian/changelog b/debian/changelog index 54c0644f..5d8c6cbb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -122,7 +122,9 @@ bash-completion (200902xx) UNRELEASED; urgency=low * Fix awk error in "modprobe -r /" completion (Closes: #512556). * Expand ~foo to dir name more eagerly to avoid quoting issues. * Fix -sourcepath handling in javadoc packages completion. - * Fix killall completion for commands with relative paths (RHBZ: #484578). + * Extract process name completion from _killall to _pnames, make it work + for others than Linux and FreeBSD. + * Fix process name completion with relative paths (RHBZ: #484578). [ Freddy Vulto ] * Restored `_display()' completion for `display' by removing -- cgit v1.2.1 From 14c641aea51016fc9f3d2a6e9dabb585491e73f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 18:51:09 +0200 Subject: Note why "ps axo comm" is not used in _pnames on Linux. --- bash_completion | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash_completion b/bash_completion index e522898b..383d23ee 100644 --- a/bash_completion +++ b/bash_completion @@ -446,6 +446,8 @@ _pnames() # containing "/" specially unless -r is given so that wouldn't quite # work either. Perhaps it'd be best to not complete these to anything # for now. + # Not using "ps axo comm" because under some Linux kernels, it + # truncates command names (see e.g. http://bugs.debian.org/497540#19) COMPREPLY=( $( compgen -W '$( command ps axo command | \ sed -e "1d; s/ .*//; s:.*/::; s/:$//;" \ -e "s/^[[(-]//; s/[])]$//" \ -- cgit v1.2.1 From db00d73296c69f38ed0193dd4e41b50da0bcfc49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 18:53:09 +0200 Subject: Use improved process name completion in pgrep in addition to killall. --- bash_completion | 4 +--- debian/changelog | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bash_completion b/bash_completion index 383d23ee..542031b5 100644 --- a/bash_completion +++ b/bash_completion @@ -1072,9 +1072,7 @@ _pgrep() COMPREPLY=() cur=`_get_cword` - COMPREPLY=( $( compgen -W '$( command ps axo command | \ - sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \ - sed -e "s/.*\///" )' -- $cur ) ) + _pnames return 0 } diff --git a/debian/changelog b/debian/changelog index 5d8c6cbb..67453a66 100644 --- a/debian/changelog +++ b/debian/changelog @@ -125,6 +125,7 @@ bash-completion (200902xx) UNRELEASED; urgency=low * Extract process name completion from _killall to _pnames, make it work for others than Linux and FreeBSD. * Fix process name completion with relative paths (RHBZ: #484578). + * Use improved process name completion in pgrep in addition to killall. [ Freddy Vulto ] * Restored `_display()' completion for `display' by removing -- cgit v1.2.1 From 9960fbfdcfa226b261c47caccd1cbfc4c260d4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 19:04:51 +0200 Subject: Enable pgrep completion if pgrep is available, not just on Linux/FreeBSD. --- bash_completion | 7 ++++--- debian/changelog | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bash_completion b/bash_completion index 542031b5..8a68c89e 100644 --- a/bash_completion +++ b/bash_completion @@ -1062,9 +1062,9 @@ _killall() } [ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall pkill -# Linux and FreeBSD pgrep(1) completion. +# pgrep(1) completion. # -[ $UNAME = Linux -o $UNAME = FreeBSD ] && +[ $UNAME = Linux ] || have pgrep && _pgrep() { local cur @@ -1076,7 +1076,8 @@ _pgrep() return 0 } -[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _pgrep pgrep +have pgrep && complete -F _pgrep pgrep + # Linux pidof(8) completion. [ $UNAME = Linux ] && complete -F _pgrep pidof diff --git a/debian/changelog b/debian/changelog index 67453a66..555e832d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -126,6 +126,7 @@ bash-completion (200902xx) UNRELEASED; urgency=low for others than Linux and FreeBSD. * Fix process name completion with relative paths (RHBZ: #484578). * Use improved process name completion in pgrep in addition to killall. + * Enable pgrep completion if pgrep is available, not just on Linux/FreeBSD. [ Freddy Vulto ] * Restored `_display()' completion for `display' by removing -- cgit v1.2.1 From d07e282122f3ec3edf207bc75d5aa783ff055c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 19:12:05 +0200 Subject: Enable pkill completion if the command is available, not just on Linux and FreeBSD. --- bash_completion | 7 ++++--- debian/changelog | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bash_completion b/bash_completion index 8a68c89e..614a7edb 100644 --- a/bash_completion +++ b/bash_completion @@ -1042,9 +1042,9 @@ _kill() } complete -F _kill kill -# Linux and FreeBSD killall(1) completion. +# killall(1) (Linux and FreeBSD) and pkill(1) completion. # -[ $UNAME = Linux -o $UNAME = FreeBSD ] && +[ $UNAME = Linux -o $UNAME = FreeBSD ] || have pkill && _killall() { local cur @@ -1060,7 +1060,8 @@ _killall() return 0 } -[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall pkill +[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall +have pkill && complete -F _killall pkill # pgrep(1) completion. # diff --git a/debian/changelog b/debian/changelog index 555e832d..4062cadb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -126,7 +126,8 @@ bash-completion (200902xx) UNRELEASED; urgency=low for others than Linux and FreeBSD. * Fix process name completion with relative paths (RHBZ: #484578). * Use improved process name completion in pgrep in addition to killall. - * Enable pgrep completion if pgrep is available, not just on Linux/FreeBSD. + * Enable pgrep and pkill completion if the commands are available, not just + on Linux and FreeBSD. [ Freddy Vulto ] * Restored `_display()' completion for `display' by removing -- cgit v1.2.1 From cdec0e5a58ed3388034c5ac74a03ff754de11338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 22:50:41 +0200 Subject: Drop hg completion, an improved version is shipped with Mercurial (contrib/bash_completion in the tarball). --- contrib/hg | 135 ------------------------------------------------------- debian/changelog | 2 + 2 files changed, 2 insertions(+), 135 deletions(-) delete mode 100644 contrib/hg diff --git a/contrib/hg b/contrib/hg deleted file mode 100644 index c053aa22..00000000 --- a/contrib/hg +++ /dev/null @@ -1,135 +0,0 @@ -# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- -# ex: ts=8 sw=8 noet filetype=sh -# -# Mercurial completion by Alexis S. L. Carvalho -# -# See: http://www.selenic.com/pipermail/mercurial/2005-August/003378.html - -_hg_commands() -{ - local commands="$(hg -v help | sed -e '1,/^list of commands:/d' \ - -e '/^global options:/Q' \ - -e '/^ [^ ]/!d; s/[,:]//g;')" - - # hide debug commands from users, but complete them if - # specifically asked for - if [[ "$cur" == de* ]]; then - commands="$commands debugcheckstate debugstate debugindex" - commands="$commands debugindexdot debugwalk" - fi - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$commands" -- "$cur") ) -} - -_hg_paths() -{ - local paths="$(hg paths | sed -e 's/ = .*$//')" - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$paths" -- "$cur" )) -} - -_hg_tags() -{ - local tags="$(hg tags | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')" - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$tags" -- "$cur") ) -} - -# this is "kind of" ugly... -_hg_count_non_option() -{ - local i count=0 - local filters="$1" - - for (( i=1; $i<=$COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" != -* ]]; then - for f in $filters; do - if [[ ${COMP_WORDS[i-1]} == $f ]]; then - continue 2 - fi - done - count=$(($count + 1)) - fi - done - - echo $(($count - 1)) -} - -_hg() -{ - local cur prev cmd opts i - - COMPREPLY=() - cur="$2" - prev="$3" - - # searching for the command - # (first non-option argument that doesn't follow -R/--repository) - for (( i=1; $i<=$COMP_CWORD; i++ )); do - if [[ ${COMP_WORDS[i]} != -* ]] \ - && [ "${COMP_WORDS[i-1]}" != -R ] \ - && [ "${COMP_WORDS[i-1]}" != --repository ]; then - cmd="${COMP_WORDS[i]}" - break - fi - done - - if [[ "$cur" == -* ]]; then - opts="$(hg -v help | sed -e '1,/^global options/d; /^ -/!d')" - - if [ -n "$cmd" ]; then - opts="$opts $(hg help "$cmd" | sed -e '/^ -/!d; s/ [^-][^ ]*//')" - fi - - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$opts" -- "$cur") ) - return - fi - - if [ "$prev" = -R ] || [ "$prev" = --repository ]; then - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" )) - return - fi - - if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then - _hg_commands - return - fi - - if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then - _hg_tags - return - fi - - case "$cmd" in - help) - _hg_commands - ;; - export|manifest|update|checkout|up|co) - _hg_tags - ;; - pull|push) - _hg_paths - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" )) - ;; - paths) - _hg_paths - ;; - clone) - local count=$(_hg_count_non_option) - if [ $count = 1 ]; then - _hg_paths - fi - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" )) - ;; - cat) - local count=$(_hg_count_non_option -o --output) - if [ $count = 2 ]; then - _hg_tags - else - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" )) - fi - ;; - *) - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" )) - ;; - esac - -} -complete -o filenames -F _hg hg diff --git a/debian/changelog b/debian/changelog index 4062cadb..b8a9c39a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -128,6 +128,8 @@ bash-completion (200902xx) UNRELEASED; urgency=low * Use improved process name completion in pgrep in addition to killall. * Enable pgrep and pkill completion if the commands are available, not just on Linux and FreeBSD. + * Drop hg completion, an improved version is shipped with Mercurial + (contrib/bash_completion in the tarball). [ Freddy Vulto ] * Restored `_display()' completion for `display' by removing -- cgit v1.2.1 From 20278a41473544d43c51095ba2e118fc7b89c0d5 Mon Sep 17 00:00:00 2001 From: Freddy Vulto Date: Sun, 15 Feb 2009 21:56:01 +0100 Subject: Reviewed `to_review/vncviewer': - added support for case-insensitive options - added support for double-dash - replaced options with options from vncviewer-4.1.1 (Ubuntu-8.10) --- to_review/vncviewer | 57 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/to_review/vncviewer b/to_review/vncviewer index 02c91051..24d90124 100644 --- a/to_review/vncviewer +++ b/to_review/vncviewer @@ -1,8 +1,11 @@ # -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- # ex: ts=8 sw=8 noet filetype=sh # -# bash completion for vncviewer +# bash completion for vncviewer (4.1.1) + +# NOTE: - VNC Viewer options are case-insensivite. Preferred case is taken from -help. +# - Both single dash (-) and double dash (--) are allowed as option prefix have vncviewer && _vncviewer() { @@ -12,29 +15,55 @@ _vncviewer() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - case $prev in - -passwd) + # Convert double dash to single dash + case ${prev/#--/-} in + # -passwd, -PasswordFile + -[pP][aA][sS][sS][wW][dD]|-[pP][aA][sS][sS][wW][oO][rR][dD][fF][iI][lL][eE]) _filedir return 0 ;; - -encodings) - COMPREPLY=( $( compgen -W 'copyrect tight hextile zlib \ - corre rre raw' -- $cur ) ) + # -PreferredEncoding + -[pP][rR][eE][fF][eE][rR][rR][eE][dD][eE][nN][cC][oO][dD][iI][nN][gG]) + COMPREPLY=( $( compgen -W 'zrle hextile raw' -- $cur ) ) return 0 ;; - -via) + # -via + -[vV][iI][aA]) _known_hosts return 0 ;; esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-help -listen -via -shared -noshared\ - -viewonly -fullscreen -noraiseonbeep -passwd -encodings\ - -bgr233 -owncmap -truecolour -truecolor -depth \ - -compresslevel -quality -nojpeg -nocursorshape \ - -x11cursor' -- $cur ) ) + if [[ "$cur" == -* || "$cur" == --* ]]; then + # Default to vncviewer camelcase options, see `vncviewer -help' + local dash options=( \ + AcceptClipboard AutoSelect DebugDelay display \ + DotWhenNoCursor FullColor FullColour FullScreen \ + geometry help listen Log \ + LowColourLevel MenuKey name Parent \ + passwd PasswordFile PointerEventInterval PreferredEncoding \ + SendClipboard SendPrimary Shared UseLocalCursor \ + via ViewOnly WMDecorationHeight WMDecorationWidth \ + ZlibLevel \ + ) + [[ "$cur" == --* ]] && dash=-- || dash=- + # Is a `nocasematch' variable available (bash > v3.1)? + if shopt nocasematch 2> /dev/null | grep -q ^nocasematch; then + # Variable `nocasematch' is available + # Use vncviewer camelcase options + local option oldNoCaseMatch=$(shopt -p nocasematch) + shopt -s nocasematch + COMPREPLY=( $( for option in "${options[@]}"; do + [[ $dash$option == "$cur"* ]] && echo $dash$option + done ) ) + eval "$oldNoCaseMatch" 2> /dev/null + else + # Variable 'nocasematch' isn't available; + # Convert completions to lowercase + COMPREPLY=( $( compgen -W "$( + echo ${options[@]/#/$dash} | tr [:upper:] [:lower:] + )" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) ) + fi else _known_hosts fi -- cgit v1.2.1 From 05505532350491c6ac9c521399acf32cada6c386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 23:56:09 +0200 Subject: lspc->lspci, add -L, add/fix -x. --- to_review/rdesktop | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/to_review/rdesktop b/to_review/rdesktop index a3a6394c..ba941eec 100644 --- a/to_review/rdesktop +++ b/to_review/rdesktop @@ -34,16 +34,17 @@ _rdesktop() return 0 ;; -r) + # FIXME: should do $nospace for the colon options COMPREPLY=( $( compgen -W 'comport: disk: lptport: \ - printer: sound: lspc scard' -- $cur ) ) + printer: sound: lspci scard' -- $cur ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -k -g -f -b -A -B \ - -e -E -m -C -D -K -S -T -N -X -a -z -X -P -r -0 -4 -5' \ - -- $cur ) ) + COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -k -g -f -b -L \ + -A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \ + -0 -4 -5' -- $cur ) ) else _known_hosts fi -- cgit v1.2.1 From 05d1c4ab9980d7434031a1ba770794bc8cb66efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 15 Feb 2009 23:59:06 +0200 Subject: rdesktop reviewed. --- contrib/rdesktop | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 1 + to_review/rdesktop | 53 ----------------------------------------------------- 3 files changed, 54 insertions(+), 53 deletions(-) create mode 100644 contrib/rdesktop delete mode 100644 to_review/rdesktop diff --git a/contrib/rdesktop b/contrib/rdesktop new file mode 100644 index 00000000..ba941eec --- /dev/null +++ b/contrib/rdesktop @@ -0,0 +1,53 @@ +# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- +# ex: ts=8 sw=8 noet filetype=sh +# +# bash completion for rdesktop + +have rdesktop && +_rdesktop() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -k) + COMPREPLY=( $( command ls \ + /usr/share/rdesktop/keymaps 2>/dev/null | \ + egrep -v '(common|modifiers)' ) ) + COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \ + $HOME/.rdesktop/keymaps 2>/dev/null ) ) + COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \ + ./keymaps 2>/dev/null ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) ) + return 0 + ;; + -a) + COMPREPLY=( $( compgen -W '8 15 16 24' -- $cur ) ) + return 0 + ;; + -x) + COMPREPLY=( $( compgen -W 'b broadband m modem l lan' \ + -- $cur ) ) + return 0 + ;; + -r) + # FIXME: should do $nospace for the colon options + COMPREPLY=( $( compgen -W 'comport: disk: lptport: \ + printer: sound: lspci scard' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -k -g -f -b -L \ + -A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \ + -0 -4 -5' -- $cur ) ) + else + _known_hosts + fi + +} && +complete -F _rdesktop rdesktop diff --git a/debian/changelog b/debian/changelog index b8a9c39a..66107ac3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ bash-completion (200902xx) UNRELEASED; urgency=low * Added net-tools (mii-tool and mii-diag) completions * Added minicom completion * Added quota-tools completion + * Added rdesktop completion [ David Paleino ] * Added .kar to Timidity completion. diff --git a/to_review/rdesktop b/to_review/rdesktop deleted file mode 100644 index ba941eec..00000000 --- a/to_review/rdesktop +++ /dev/null @@ -1,53 +0,0 @@ -# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- -# ex: ts=8 sw=8 noet filetype=sh -# -# bash completion for rdesktop - -have rdesktop && -_rdesktop() -{ - local cur prev - - COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - - case $prev in - -k) - COMPREPLY=( $( command ls \ - /usr/share/rdesktop/keymaps 2>/dev/null | \ - egrep -v '(common|modifiers)' ) ) - COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \ - $HOME/.rdesktop/keymaps 2>/dev/null ) ) - COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \ - ./keymaps 2>/dev/null ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) ) - return 0 - ;; - -a) - COMPREPLY=( $( compgen -W '8 15 16 24' -- $cur ) ) - return 0 - ;; - -x) - COMPREPLY=( $( compgen -W 'b broadband m modem l lan' \ - -- $cur ) ) - return 0 - ;; - -r) - # FIXME: should do $nospace for the colon options - COMPREPLY=( $( compgen -W 'comport: disk: lptport: \ - printer: sound: lspci scard' -- $cur ) ) - return 0 - ;; - esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -k -g -f -b -L \ - -A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \ - -0 -4 -5' -- $cur ) ) - else - _known_hosts - fi - -} && -complete -F _rdesktop rdesktop -- cgit v1.2.1