Skip to content

Commit

Permalink
m*: Support completing arg of last bundled short option
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 26, 2018
1 parent 1397fa7 commit 8f82fd9
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 76 deletions.
12 changes: 6 additions & 6 deletions completions/make
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,23 @@ _make()
local file makef makef_dir=( "-C" "." ) makef_inc i

case $prev in
-f|--file|--makefile|-o|--old-file|--assume-old|-W|--what-if|\
--new-file|--assume-new)
--file|--makefile|--old-file|--assume-old|--what-if| --new-file|\
--assume-new|-!(-*)[foW])
_filedir
return
;;
-I|--include-dir|-C|--directory|-m)
--include-dir|--directory|-!(-*)[ICm])
_filedir -d
return
;;
-E)
-!(-*)E)
COMPREPLY=( $( compgen -v -- "$cur" ) )
return
;;
--eval|-D|-V|-x)
--eval|-!(-*)[DVx])
return
;;
--jobs|-j)
--jobs|-!(-*)j)
COMPREPLY=( $( compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur" ) )
return
;;
Expand Down
14 changes: 7 additions & 7 deletions completions/man
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ _man()
local mansect="@([0-9lnp]|[0-9][px]|3?(gl|pm))"

case $prev in
-C|--config-file)
--config-file|-!(-*)C)
_filedir conf
return
;;
-l|--local-file)
--local-file|-!(-*)l)
_filedir "$manext"
return
;;
-M|--manpath)
--manpath|-!(-*)M)
_filedir -d
return
;;
-P|--pager)
--pager|-!(-*)P)
compopt -o filenames
COMPREPLY=( $( compgen -c -- "$cur" ) )
return
;;
-p|--preprocessor)
--preprocessor|-!(-*)p)
COMPREPLY=( $( compgen -W 'e p t g r v' -- "$cur" ) )
return
;;
-L|--locale|-m|--systems|-e|--extension|-r|--prompt|-R|--recode|\
-E|--encoding)
--locale|--systems|--extension|--prompt|--recode|--encoding|\
-!(-*)[LmerRE])
return
;;
esac
Expand Down
9 changes: 2 additions & 7 deletions completions/mc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ _mc()
_init_completion -s || return

case $prev in
-e|--edit|-v|--view|-l|--ftplog|-P|--printwd)
--edit|--view|--ftplog|--printwd|-!(-*)[evlP])
_filedir
return
;;
-C|--colors|-D|--debuglevel)
# argument required but no completions available
return
;;
-h|--help|--help-*|-V|--version)
# all other arguments are noop with these
--help|--help-*|--version|--colors|--debuglevel|-!(-*)[hVCD])
return
;;
esac
Expand Down
20 changes: 10 additions & 10 deletions completions/mdadm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ _mdadm_raid_level()

for (( i=1; i < cword; i++ )); do
case ${words[i]} in
-C|--create)
-!(-*)C*|--create)
mode=create
break
;;
-B|--build)
-!(-*)B*|--build)
mode=build
break
;;
Expand Down Expand Up @@ -74,23 +74,23 @@ _mdadm()
_init_completion -s || return

case $prev in
-c|--config|-b|--bitmap|--backup-file)
--config|--bitmap|--backup-file|-!(-*)[cb])
_filedir
return
;;
-l|--level)
--level|-!(-*)l)
_mdadm_raid_level
return
;;
-p|--layout|--parity)
--layout|--parity|-!(-*)p)
_mdadm_raid_layout
return
;;
-a|--auto)
--auto|-!(-*)a)
_mdadm_auto_flag
return
;;
-U|--update)
--update|-!(-*)U)
_mdadm_update_flag
return
;;
Expand All @@ -107,21 +107,21 @@ _mdadm()
--monitor --grow" -- "$cur" ) )
else
case ${words[cword-1]} in
-A|--assemble)
--assemble|-!(-*)A*)
COMPREPLY=( $( compgen -W "$options --uuid= --super-minor=
--name= --force --run --no-degraded --auto= --bitmap=
--backup-file= --update= --auto-update-homehost" \
-- "$cur" ) )
;;
-B|-C|-G|--build|--create|--grow)
--build|--create|--grow|-!(-*)[BCG]*)
COMPREPLY=( $( compgen -W "$options --raid-devices=
--spare-devices= --size= --chunk= --rounding= --level=
--layout= --parity= --bitmap= --bitmap-chunk=
--write-mostly --write-behind= --assume-clean
--backup-file= --name= --run --force --auto=" \
-- "$cur" ) )
;;
-F|--follow|--monitor)
--follow|--monitor|-!(-*)F)
COMPREPLY=( $( compgen -W "$options --mail --program
--alert --syslog --delay --daemonise --pid-file
--oneshot --test" -- "$cur" ) )
Expand Down
6 changes: 3 additions & 3 deletions completions/medusa
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ _medusa()
_init_completion || return

case $prev in
-h)
-*h)
_known_hosts_real -- "$cur"
return
;;
-H|-U|-P|-C|-O)
-*[HUPCO])
_filedir
return
;;
-M)
-*M)
COMPREPLY=( $( compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' \
| command sed -e 's/\.mod$//')" ) )
return
Expand Down
4 changes: 2 additions & 2 deletions completions/mii-tool
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ _mii_tool()
_init_completion -s || return

case $prev in
-F|--force)
--force|-!(-*)F)
COMPREPLY=( $( compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD
10baseT-HD' -- "$cur" ) )
return
;;
-A|--advertise)
--advertise|-!(-*)A)
COMPREPLY=( $( compgen -W '100baseT4 100baseTx-FD 100baseTx-HD
10baseT-FD 10baseT-HD' -- "$cur" ) )
return
Expand Down
6 changes: 3 additions & 3 deletions completions/minicom
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ _minicom()
_init_completion -s || return

case $prev in
--attrib|--color|-a|-c)
--attrib|--color|-!(-*)[ac])
COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
return
;;
--script|--capturefile|-S|-C)
--script|--capturefile|-!(-*)[SC])
_filedir
return
;;
--ptty|-p)
--ptty|-!(-*)p)
COMPREPLY=( $( printf '%s\n' /dev/tty* ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \
-- "$cur" ) )
Expand Down
2 changes: 1 addition & 1 deletion completions/mktemp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _mktemp()
--help|--version|--suffix)
return
;;
--tmpdir|-p)
--tmpdir|-!(-*)p)
_filedir -d
return
;;
Expand Down
6 changes: 3 additions & 3 deletions completions/modinfo
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ _modinfo()
_init_completion -s || return

case "$prev" in
--field|-F)
--field|-!(-*)F)
COMPREPLY=( $( compgen -W 'alias author depends description
filename firmware license parm srcversion staging vermagic
version' -- "${cur,,}" ) )
return
;;
--set-version|-k)
--set-version|-!(-*)k)
_kernel_versions
return
;;
Expand All @@ -28,7 +28,7 @@ _modinfo()

local i version=$(uname -r)
for (( i=${#words[@]}-1; i>0; i-- )); do
if [[ ${words[i]} == -@(k|-set-version) ]]; then
if [[ ${words[i]} == -@(!(-*)k*|-set-version) ]]; then
version=${words[i+1]}
break
fi
Expand Down
16 changes: 8 additions & 8 deletions completions/modprobe
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ _modprobe()
_init_completion -s || return

case "$prev" in
-h|--help|-V|--version)
--help|--version|-!(-*)[hV])
return
;;
-C|--config)
--config|-!(-*)C)
_filedir
return
;;
-d|--dirname|-t|--type)
--dirname|--type|-!(-*)[dt])
_filedir -d
return
;;
-S|--set-version)
--set-version|-!(-*)S)
_kernel_versions
return
;;
Expand All @@ -43,19 +43,19 @@ _modprobe()
local i mode=insert module= version=$(uname -r)
for (( i=1; i < $cword; i++ )); do
case "${words[i]}" in
-r|--remove)
--remove|-!(-*)r*)
mode=remove
;;
-l|--list)
--list|-!(-*)l*)
mode=list
;;
--dump-modversions)
mode=file
;;
-S|--set-version)
--set-version|-!(-*)S)
version=${words[i+1]} # -S is not $prev and not $cur
;;
-C|--config|-d|--dirname|-t|--type)
--config|--dirname|--type|-!(-*)[Cdt])
((i++)) # skip option and its argument
;;
-*)
Expand Down
4 changes: 2 additions & 2 deletions completions/mr
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ _mr() {

# Complete top-level options and commands.
case $prev in
-c|--config)
--config|-!(-*)c)
_filedir
return
;;
-d|--directory)
--directory|-!(-*)d)
_filedir -d
return
;;
Expand Down
6 changes: 3 additions & 3 deletions completions/mutt
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ _mutt()
;;
*)
case $prev in
-a|-f|-F|-H|-i)
-*[afFHi])
_muttfiledir "$cur"
return
;;
-A)
-*A)
_muttaliases "$cur"
return
;;
-e|-m|-Q|-s|-h|-p|-R|-v|-y|-z|-Z)
-*[emQshpRvyzZ])
return
;;
*)
Expand Down
21 changes: 9 additions & 12 deletions completions/mysql
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ _mysql()
_init_completion -s || return

case $prev in
-u|--user)
--user|-!(-*)u)
COMPREPLY=( $( compgen -u -- "$cur" ) )
return
;;
-D|--database)
--database|-!(-*)D)
COMPREPLY=( $( compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur" ) )
return
;;

-h|--host)
--host|-!(-*)h)
_known_hosts_real -- "$cur"
return
;;
Expand All @@ -33,7 +33,7 @@ _mysql()
_filedir -d
return
;;
-S|--socket)
--socket|-!(-*)S)
_filedir sock
return
;;
Expand All @@ -45,16 +45,13 @@ _mysql()
_filedir
return
;;
--default-character-set|-P|--port|--set-variable|\
--ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|\
--connect_timeout|--max_allowed_packet|--prompt|\
--net_buffer_length|--select_limit|--max_join_size|\
--server-arg|--debug|--delimiter|--execute|-e|--pager)
# Argument required but no completions available
--default-character-set|--port|--set-variable|--ssl-ca|--ssl-cert|\
--ssl-cipher|--ssl-key|--connect_timeout|--max_allowed_packet|\
--prompt|--net_buffer_length|--select_limit|--max_join_size|\
--server-arg|--debug|--delimiter|--execute|--pager|-!(-*)[Pe])
return
;;
'-?'|-I|--help|-V|--version)
# All other options are noop with these
--help|--version|-!(-*)[?IV])
return
;;
esac
Expand Down
Loading

0 comments on commit 8f82fd9

Please sign in to comment.