*: Invoke command to be completed, not its basename
This commit is contained in:
parent
7d66285b42
commit
7d3de619d1
@ -105,7 +105,7 @@ _7z()
|
||||
else
|
||||
if [[ ${words[1]} == d ]]; then
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( compgen -W "$( printf '%s\n' $( 7z l ${words[2]} \
|
||||
COMPREPLY=( $( compgen -W "$( printf '%s\n' $( $1 l ${words[2]} \
|
||||
-slt 2>/dev/null | sed -n '/^Path =/s/^Path = \(.*\)$/\1/p' \
|
||||
2>/dev/null | tail -n+2 ) )" -- "$cur" ) )
|
||||
compopt -o filenames
|
||||
|
@ -22,12 +22,12 @@ _abook()
|
||||
|
||||
case $prev in
|
||||
--informat)
|
||||
COMPREPLY=( $( compgen -W "$(abook --formats | \
|
||||
COMPREPLY=( $( compgen -W "$($1 --formats | \
|
||||
sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--outformat)
|
||||
COMPREPLY=( $( compgen -W "$(abook --formats | \
|
||||
COMPREPLY=( $( compgen -W "$($1 --formats | \
|
||||
sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -18,7 +18,7 @@ _brctl()
|
||||
show)
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "$(brctl show | \
|
||||
COMPREPLY=( $( compgen -W "$($1 show | \
|
||||
awk 'NR>1 {print $1}' )" -- "$cur" ) )
|
||||
esac
|
||||
;;
|
||||
|
@ -10,22 +10,22 @@ _cvsps()
|
||||
return 0
|
||||
;;
|
||||
-s)
|
||||
COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
|
||||
COMPREPLY=( $( compgen -W "$( $1 2>/dev/null |
|
||||
awk '/^PatchSet:?[ \t]/ { print $2 }' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-a)
|
||||
COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
|
||||
COMPREPLY=( $( compgen -W "$( $1 2>/dev/null |
|
||||
awk '/^Author:[ \t]/ { print $2 }' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-b)
|
||||
COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
|
||||
COMPREPLY=( $( compgen -W "$( $1 2>/dev/null |
|
||||
awk '/^Branch:[ \t]/ { print $2 }' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-r)
|
||||
COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
|
||||
COMPREPLY=( $( compgen -W "$( $1 2>/dev/null |
|
||||
awk '/^Tag:[ \t]+[^(]/ { print $2 }' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -42,12 +42,12 @@ _getent()
|
||||
return 0
|
||||
;;
|
||||
protocols|networks|ahosts|ahostsv4|ahostsv6|rpc)
|
||||
COMPREPLY=( $( compgen -W "$( getent $db | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 $db | \
|
||||
awk '{ print $1 }' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
aliases|shadow|gshadow)
|
||||
COMPREPLY=( $( compgen -W "$( getent $db | cut -d: -f1 )" \
|
||||
COMPREPLY=( $( compgen -W "$( $1 $db | cut -d: -f1 )" \
|
||||
-- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -12,13 +12,13 @@ _gpg()
|
||||
;;
|
||||
--export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key)
|
||||
# return list of public keys
|
||||
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | \
|
||||
sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \
|
||||
-ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-r|--recipient)
|
||||
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | \
|
||||
sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) )
|
||||
if [[ -e ~/.gnupg/gpg.conf ]]; then
|
||||
COMPREPLY+=( $( compgen -W "$( sed -ne \
|
||||
@ -30,7 +30,7 @@ _gpg()
|
||||
esac
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '$(gpg --dump-options)' -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W '$($1 --dump-options)' -- "$cur" ) )
|
||||
fi
|
||||
} &&
|
||||
complete -F _gpg -o default gpg
|
||||
|
@ -16,13 +16,13 @@ _gpg2()
|
||||
;;
|
||||
--export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key)
|
||||
# return list of public keys
|
||||
COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | \
|
||||
sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \
|
||||
-ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-r|--recipient)
|
||||
COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | \
|
||||
sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) )
|
||||
if [[ -e ~/.gnupg/gpg.conf ]]; then
|
||||
COMPREPLY+=( $( compgen -W "$( sed -ne \
|
||||
@ -34,7 +34,7 @@ _gpg2()
|
||||
esac
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '$(gpg2 --dump-options)' -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W '$($1 --dump-options)' -- "$cur" ) )
|
||||
fi
|
||||
} &&
|
||||
complete -F _gpg2 -o default gpg2
|
||||
|
@ -23,19 +23,19 @@ _gphoto2()
|
||||
return 0
|
||||
;;
|
||||
--port)
|
||||
COMPREPLY=( $(compgen -W "$( gphoto2 --list-ports 2>/dev/null | \
|
||||
COMPREPLY=( $(compgen -W "$( $1 --list-ports 2>/dev/null | \
|
||||
tail -n +4 | awk '{ print $1 }' )" -- "$cur") )
|
||||
__ltrim_colon_completions "$cur"
|
||||
return 0
|
||||
;;
|
||||
--camera)
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $(compgen -W "$( gphoto2 --list-cameras 2>/dev/null | \
|
||||
COMPREPLY=( $(compgen -W "$( $1 --list-cameras 2>/dev/null | \
|
||||
tail -n +3 | awk -F'"' '{ print $2 }' )" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
--get-config|--set-config|--set-config-index|--set-config-value)
|
||||
COMPREPLY=( $(compgen -W "$( gphoto2 --list-config 2>/dev/null \
|
||||
COMPREPLY=( $(compgen -W "$( $1 --list-config 2>/dev/null \
|
||||
)" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
|
@ -11,7 +11,7 @@ _ipv6calc()
|
||||
;;
|
||||
-I|--in|-O|--out|-A|--action)
|
||||
# With ipv6calc < 0.73.0, -m does nothing here, so use sed instead.
|
||||
COMPREPLY=( $( compgen -W "$( ipv6calc "$prev" -h 2>&1 | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 "$prev" -h 2>&1 | \
|
||||
sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p' )" \
|
||||
-- "$cur" ) )
|
||||
return 0
|
||||
|
@ -12,23 +12,23 @@ _mcrypt()
|
||||
return 0
|
||||
;;
|
||||
-o|--keymode)
|
||||
COMPREPLY=( $( compgen -W '$( mcrypt --list-keymodes \
|
||||
COMPREPLY=( $( compgen -W '$( $1 --list-keymodes \
|
||||
2>/dev/null )' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-m|--mode)
|
||||
COMPREPLY=( $( compgen -W "$( mcrypt --list \
|
||||
COMPREPLY=( $( compgen -W "$( $1 --list \
|
||||
2>/dev/null | sed -e 's/.*: //' -e 's/ $//' | \
|
||||
sort -u )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-a|--algorithm)
|
||||
COMPREPLY=( $( compgen -W "$( mcrypt --list 2>/dev/null | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 --list 2>/dev/null | \
|
||||
awk '{print $1}' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-h|--hash)
|
||||
COMPREPLY=( $( compgen -W '$( mcrypt --list-hash 2>/dev/null | \
|
||||
COMPREPLY=( $( compgen -W '$( $1 --list-hash 2>/dev/null | \
|
||||
sed -e 1d )' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -15,7 +15,7 @@ _medusa()
|
||||
return 0
|
||||
;;
|
||||
-M)
|
||||
COMPREPLY=( $( compgen -W "$(medusa -d | awk '/^ +\+/ {print $2}' \
|
||||
COMPREPLY=( $( compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' \
|
||||
| sed -e 's/\.mod$//')" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -51,7 +51,7 @@ _mount()
|
||||
COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" ) )
|
||||
elif [[ ! -e /etc/fstab ]]; then
|
||||
# probably Cygwin
|
||||
COMPREPLY=( $( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "$( $1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) )
|
||||
else
|
||||
# probably BSD
|
||||
COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab )" -- "$cur" ) )
|
||||
|
@ -7,13 +7,13 @@ _msynctool()
|
||||
|
||||
case $words in
|
||||
--configure)
|
||||
COMPREPLY=( $( compgen -W "$(msynctool --showgroup \
|
||||
COMPREPLY=( $( compgen -W "$($1 --showgroup \
|
||||
$prev | awk '/^Member/ {print $2}' | sed \
|
||||
-e 's/:$//' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--addmember)
|
||||
COMPREPLY=( $( compgen -W '$(msynctool --listplugins \
|
||||
COMPREPLY=( $( compgen -W '$($1 --listplugins \
|
||||
| sed -e '1d' )' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
@ -21,12 +21,12 @@ _msynctool()
|
||||
|
||||
case $prev in
|
||||
--configure|--addgroup|--delgroup|--showgroup|--sync|--addmember)
|
||||
COMPREPLY=( $( compgen -W '$(msynctool --listgroups \
|
||||
COMPREPLY=( $( compgen -W '$($1 --listgroups \
|
||||
| sed -e '1d' )' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--showformats|--filter-objtype|--slow-sync)
|
||||
COMPREPLY=( $( compgen -W '$(msynctool --listobjects \
|
||||
COMPREPLY=( $( compgen -W '$($1 --listobjects \
|
||||
| sed -e '1d' )' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -89,7 +89,7 @@ _openssl()
|
||||
return 0
|
||||
;;
|
||||
-cipher)
|
||||
COMPREPLY=( $( IFS=: compgen -W "$( openssl ciphers )" \
|
||||
COMPREPLY=( $( IFS=: compgen -W "$( $1 ciphers )" \
|
||||
-- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -35,7 +35,7 @@ _pkg_config()
|
||||
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
||||
else
|
||||
COMPREPLY=( $( compgen -W "$( pkg-config --list-all \
|
||||
COMPREPLY=( $( compgen -W "$( $1 --list-all \
|
||||
2>/dev/null | awk '{print $1}' )" -- "$cur" ) )
|
||||
fi
|
||||
} &&
|
||||
|
@ -26,17 +26,17 @@ _qemu()
|
||||
return 0
|
||||
;;
|
||||
-soundhw)
|
||||
COMPREPLY=( $( compgen -W "$( qemu -soundhw ? | awk \
|
||||
COMPREPLY=( $( compgen -W "$( $1 -soundhw ? | awk \
|
||||
'/^[[:lower:]]/ {print $1}' ) all" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-M)
|
||||
COMPREPLY=( $( compgen -W "$( qemu -M ? | awk \
|
||||
COMPREPLY=( $( compgen -W "$( $1 -M ? | awk \
|
||||
'/^[[:lower:]]/ {print $1}' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-cpu)
|
||||
COMPREPLY=( $( compgen -W "$( qemu -cpu ? | awk \
|
||||
COMPREPLY=( $( compgen -W "$( $1 -cpu ? | awk \
|
||||
'{print $2}' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
@ -82,7 +82,7 @@ _qemu()
|
||||
return 0
|
||||
;;
|
||||
-watchdog)
|
||||
COMPREPLY=( $( compgen -W "$( qemu -watchdog ? 2>&1 | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 -watchdog ? 2>&1 | \
|
||||
awk '{print $1}' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -15,7 +15,7 @@ _rfkill()
|
||||
;;
|
||||
2)
|
||||
if [[ $prev == block || $prev == unblock ]]; then
|
||||
COMPREPLY=( $( compgen -W "$(rfkill list | awk -F: \
|
||||
COMPREPLY=( $( compgen -W "$($1 list | awk -F: \
|
||||
'/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \
|
||||
wwan gps" -- "$cur" ) )
|
||||
fi
|
||||
|
@ -191,7 +191,7 @@ _svk()
|
||||
--delete' -- "$cur" ) )
|
||||
;;
|
||||
sync)
|
||||
COMPREPLY=( $( compgen -W "$( svk mirror --list \
|
||||
COMPREPLY=( $( compgen -W "$( $1 mirror --list \
|
||||
2>/dev/null | awk '/^\//{print $1}' )" -- "$cur" ) )
|
||||
;;
|
||||
co|checkout|push|pull)
|
||||
@ -200,7 +200,7 @@ _svk()
|
||||
else
|
||||
path=//
|
||||
fi
|
||||
COMPREPLY=( $( compgen -W "$( svk list $path 2>/dev/null | \
|
||||
COMPREPLY=( $( compgen -W "$( $1 list $path 2>/dev/null | \
|
||||
sed -e 's|\(.*\)|'$path'\1|')" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
|
@ -7,7 +7,7 @@ _xfreerdp()
|
||||
|
||||
case $prev in
|
||||
-k)
|
||||
COMPREPLY=( $( compgen -W "$(xfreerdp --kbd-list | \
|
||||
COMPREPLY=( $( compgen -W "$($1 --kbd-list | \
|
||||
awk '/^0x/ {print $1}')" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
Loading…
x
Reference in New Issue
Block a user