Clean up/compact various globs.

master
Ville Skyttä 2013-05-09 13:42:32 +03:00
parent bb0739fafd
commit d99c2203b9
15 changed files with 24 additions and 27 deletions

View File

@ -1888,7 +1888,7 @@ _install_xspec '!*.fig' xfig
_install_xspec '!*.@(mid?(i)|cmf)' playmidi
_install_xspec '!*.@(mid?(i)|rmi|rcp|[gr]36|g18|mod|xm|it|x3m|s[3t]m|kar)' timidity
_install_xspec '!*.@(669|abc|am[fs]|d[bs]m|dmf|far|it|mdl|m[eo]d|mid?(i)|mt[2m]|okta|p[st]m|s[3t]m|ult|umx|wav|xm)' modplugplay modplug123
_install_xspec '*.@(o|so|so.!(conf|*/*)|a|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim view rview rgvim rgview gview emacs xemacs sxemacs kate kwrite
_install_xspec '*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim view rview rgvim rgview gview emacs xemacs sxemacs kate kwrite
_install_xspec '!*.@(zip|z|gz|tgz)' bzme
# konqueror not here on purpose, it's more than a web/html browser
_install_xspec '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx galeon dillo elinks amaya firefox mozilla-firefox iceweasel google-chrome chromium-browser epiphany

View File

@ -198,7 +198,7 @@ _svn()
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
else
if [[ "$command" == @(help|h|\?) ]]; then
if [[ "$command" == @(help|[h?]) ]]; then
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
else
_filedir
@ -271,7 +271,7 @@ _svnadmin()
options+=" --help"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
else
if [[ "$command" == @(help|h|\?) ]]; then
if [[ "$command" == @(help|[h?]) ]]; then
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
else
_filedir
@ -329,7 +329,7 @@ _svnlook()
options+=" --help"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
else
if [[ "$command" == @(help|h|\?) ]]; then
if [[ "$command" == @(help|[h?]) ]]; then
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
else
_filedir

View File

@ -8,7 +8,7 @@ _repomanage()
local cur prev words cword split
_init_completion -s || return
[[ "$prev" == -@(h|-help|k|-keep) ]] && return 0
[[ "$prev" == -@([hk]|-help|-keep) ]] && return 0
$split && return

View File

@ -71,7 +71,7 @@ _cppcheck()
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
_filedir @(cpp|cxx|cc|c++|c|h|hpp|hxx|h++|tpp|txx)
_filedir @([cht]pp|[cht]xx|cc|[ch]++|[ch])
fi
} &&
complete -F _cppcheck cppcheck

View File

@ -41,7 +41,7 @@ _crontab()
fi
# do filenames only if we did not have -l, -r, or -e
[[ "${words[@]}" == *\ -@(l|r|e)* ]] || _filedir
[[ "${words[@]}" == *\ -[lre]* ]] || _filedir
} &&
complete -F _crontab crontab

View File

@ -195,7 +195,7 @@ _cvs()
fi
;;
annotate)
[[ "$prev" == -@(r|D) ]] && return 0
[[ "$prev" == -[rD] ]] && return 0
if [[ "$cur" == -* ]]; then
_cvs_command_options "$1" $mode

View File

@ -5,7 +5,7 @@ _dot()
local cur prev words cword
_init_completion -n := || return
[[ $prev == -@(V|\?) ]] && return
[[ $prev == -[V?] ]] && return
case $cur in
-G*|-N*|-E*|-l?*|-q?*|-s?*|-Ln*|-LU*|-LC*|-LT*)
@ -34,7 +34,7 @@ _dot()
if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n
-n1 -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' -- "$cur" ) )
[[ $COMPREPLY == -@(G|N|E|T|K|o|L[nUCT]) ]] && compopt -o nospace
[[ $COMPREPLY == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace
return
fi

View File

@ -36,9 +36,7 @@ _nc()
# Complete 1st non-option arg only
local i
for (( i=1; i < cword; i++ )); do
[[ ${words[i]} != -* && \
${words[i-1]} != @(-I|-i|-O|-P|-p|-s|-T|-V|-w|-X|-x) ]] && \
return
[[ ${words[i]} != -* && ${words[i-1]} != -[IiOPpsTVwXx] ]] && return
done
_known_hosts_real "$cur"

View File

@ -127,7 +127,7 @@ _perldoc()
-- "$cur" ) )
fi
fi
_filedir 'p@(l|m|od)'
_filedir 'p@([lm]|od)'
fi
} &&
complete -F _perldoc -o bashdefault perldoc

View File

@ -43,13 +43,13 @@ _pkg-get()
if [[ "${COMP_WORDS[$i]}" == -s ]]; then
url="${COMP_WORDS[$((i+1))]}"
fi
if [[ "${COMP_WORDS[$i]}" == @(available|-a|describe|-D|download|-d|install|-i|list|updatecatalog|-U|upgrade|-u) ]]; then
if [[ "${COMP_WORDS[$i]}" == @(-[aDdiUu]|available|describe|download|install|list|updatecatalog|upgrade) ]]; then
command="${COMP_WORDS[$i]}"
fi
done
if [[ -n "$command" ]]; then
if [[ "$command" == @(describe|-D|download|-d|install|-i) ]]; then
if [[ "$command" == @(-[Ddi]|describe|download|install) ]]; then
catalog_file=$(_pkg-get_get_catalog_file "$url")
if [[ -f $catalog_file ]]; then
local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file)

View File

@ -23,28 +23,28 @@ _pkgutil()
i=$cword
while [[ $((i--)) -gt 1 ]]; do
if [[ "${words[$i]}" == @(-t|--temp) ]]; then
if [[ "${words[$i]}" == -@(t|-temp) ]]; then
local url="${words[$((i+1))]}"
local catalog=$(_pkgutil_url2catalog "$url")
catalog_files=("$catalog")
elif [[ "${words[$i]}" == --config ]]; then
configuration_files=( "$(dequote ${words[$((i+1))]})" )
elif [[ "${words[$i]}" == @(-i|--install|-u|--upgrade|-r|--remove|-d|--download|-a|--available|-c|--compare|-U|--catalog|-S|--stream) ]]; then
elif [[ "${words[$i]}" == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then
command="${words[$i]}"
fi
done
if [[ "$prev" == @(-W|--workdir|-P|--pkgdir|-R|--rootpath) ]]; then
if [[ "$prev" == -@([WPR]|-workdir|-pkgdir|-rootpath) ]]; then
_filedir -d
return 0
fi
if [[ "$prev" == @(-o|--output|--config) ]]; then
if [[ "$prev" == -@(o|-output|-config) ]]; then
_filedir
return 0
fi
if [[ "$prev" == @(-p|--param) ]]; then
if [[ "$prev" == -@(p|-param) ]]; then
compopt -o nospace
COMPREPLY=( $(compgen -W "mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg: use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error: exclude_pattern: gpg_homedir: root_path: deptree_filter_common: show_current: catalog_not_cached: catalog_update:" -- $cur) )
return 0
@ -73,7 +73,7 @@ _pkgutil()
catalog_files=( "${catalog_files[@]}" "$catalog" )
done
if [[ "$command" == @(--download|-d|--install|-i|--upgrade|-u|s|--stream) ]]; then
if [[ "$command" == -@([dius]|-download|-install|-upgrade|-stream) ]]; then
local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "${catalog_files[@]}")
COMPREPLY=( $(compgen -W "${packages_list}" -- $cur) )

View File

@ -29,8 +29,7 @@ _python()
return 0
;;
!(?(*/)python*([0-9.])|-?))
[[ $cword -lt 2 || ${words[cword-2]} != -@(Q|W) ]] \
&& _filedir
[[ $cword -lt 2 || ${words[cword-2]} != -[QW] ]] && _filedir
;;
esac

View File

@ -25,7 +25,7 @@ _slapt_src()
local i t
# search for last action (-i|-w|-b|-f)
for (( i=${#words[@]}-1; i>0; i-- )); do
if [[ ${words[i]} == -@(i|w|f|b|-install|-show|-build|-fetch) ]]; then
if [[ ${words[i]} == -@([iwfb]|-install|-show|-build|-fetch) ]]; then
t="all"
break
fi

View File

@ -20,7 +20,7 @@ _sudo()
mode=edit
break
fi
[[ ${COMP_WORDS[i]} == -@(u|U|g|C|p) ]] && ((i++))
[[ ${COMP_WORDS[i]} == -[uUgCp] ]] && ((i++))
done
case "$prev" in

View File

@ -100,7 +100,7 @@ _wget()
;;
-Q|--quota|--limit-rate|--warc-max-size)
# expect size
if [[ $cur == *@(k|m) ]]; then
if [[ $cur == *[km] ]]; then
COMPREPLY=( $( compgen -W "$cur" ) )
elif [[ $cur ]]; then
COMPREPLY=( $( compgen -P "$cur" -W "{0..9} k m" ) )