Permalink
Browse files

[bash] Update completions

  • Loading branch information...
guns committed Sep 13, 2013
1 parent 64428f6 commit 68adb8c3b136c9518895f5b78864ea7a987e4760
View
@@ -625,6 +625,24 @@ _variables()
COMPREPLY+=( $( compgen -P ${BASH_REMATCH[1]} -S "$suffix" -v -- \
"${BASH_REMATCH[2]}" ) )
return 0
+ else
+ case $prev in
+ TZ)
+ cur=/usr/share/zoneinfo/$cur
+ _filedir
+ for i in ${!COMPREPLY[@]}; do
+ if [[ ${COMPREPLY[i]} == *.tab ]]; then
+ unset COMPREPLY[i]
+ continue
+ elif [[ -d ${COMPREPLY[i]} ]]; then
+ COMPREPLY[i]+=/
+ compopt -o nospace
+ fi
+ COMPREPLY[i]=${COMPREPLY[i]#/usr/share/zoneinfo/}
+ done
+ return 0
+ ;;
+ esac
fi
return 1
}
@@ -1532,7 +1550,7 @@ _known_hosts_real()
# append any available aliases from config files
if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
- local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
+ local hosts=$( sed -ne 's/^['"$'\t '"']*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
COMPREPLY+=( $( compgen -P "$prefix$user" \
-S "$suffix" -W "$hosts" -- "$cur" ) )
fi
@@ -1761,7 +1779,7 @@ _longopt()
return 0
;;
--+([-a-z0-9_]))
- local argtype=$( $1 --help 2>&1 | sed -ne \
+ local argtype=$( LC_ALL=C $1 --help 2>&1 | sed -ne \
"s|.*$prev\[\{0,1\}=[<[]\{0,1\}\([-A-Za-z0-9_]\{1,\}\).*|\1|p" )
case ${argtype,,} in
*dir*)
@@ -1779,7 +1797,7 @@ _longopt()
$split && return 0
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
+ COMPREPLY=( $( compgen -W "$( LC_ALL=C $1 --help 2>&1 | \
sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\1/p' | sort -u )" \
-- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
View
@@ -0,0 +1,39 @@
+# bash completion for 2to3 -*- shell-script -*-
+
+_2to3()
+{
+ local cur prev words cword split
+ _init_completion -s || return
+
+ case $prev in
+ -h|--help|--add-suffix)
+ return
+ ;;
+ -f|--fix|-x|--nofix)
+ COMPREPLY=( $( compgen -W \
+ "$( $1 --list-fixes 2>/dev/null | sed -e 1d )" -- "$cur" ) )
+ return
+ ;;
+ -j|--processes)
+ COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) )
+ return
+ ;;
+ -o|--output-dir)
+ _filedir -d
+ return
+ ;;
+ esac
+
+ $split && return
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ return
+ fi
+
+ _filedir py
+} &&
+complete -F _2to3 2to3
+
+# ex: ts=4 sw=4 et filetype=sh
View
@@ -10,14 +10,49 @@ _7z()
return
fi
+ local mode
+ [[ ${words[1]} == @(a|d|u) ]] && mode=w || mode=r
+
case $cur in
- -mhe=*)
+ -ao*)
+ COMPREPLY=( $( compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}" ) )
+ return
+ ;;
+ -?(a)[ix]*)
+ local opt
+ if [[ $cur == -a[ix]* ]]; then
+ opt=${cur:0:3} cur=${cur:3}
+ else
+ opt=${cur:0:2} cur=${cur:2}
+ fi
+ if [[ $cur != *[@\!]* ]]; then
+ COMPREPLY=( $( compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \
+ -- "$cur" ) )
+ elif [[ $cur == ?(r@(-|0|))@* ]]; then
+ local x tmp
+ x=$( compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}" ) &&
+ while read -r tmp; do
+ COMPREPLY+=( "$tmp" )
+ done <<< "$x"
+ compopt -o filenames
+ fi
+ return
+ ;;
+ -mhe=*|-mhc=*|-ms=*|-mt=*)
COMPREPLY=( $( compgen -W 'on off' -- "${cur#*=}" ) )
return
;;
+ -mx=*)
+ COMPREPLY=( $( compgen -W '0 1 3 5 7 9' -- "${cur#*=}" ) )
+ return
+ ;;
-o*|-w?*)
+ local x tmp
+ x=$( compgen -P${cur:0:2} -S/ -d -- "${cur:2}" ) &&
+ while read -r tmp; do
+ COMPREPLY+=( "$tmp" )
+ done <<< "$x"
compopt -o nospace -o filenames
- COMPREPLY=( $( compgen -P${cur:0:2} -S/ -d -- "${cur:2}" ) )
return
;;
-r?*)
@@ -34,29 +69,49 @@ _7z()
return
;;
-t*)
- COMPREPLY=( $( compgen -P${cur:0:2} -W '7z zip gzip bzip2 tar' \
- -- "${cur:2}" ) )
+ if [[ $mode == w ]]; then
+ COMPREPLY=( $( compgen -P${cur:0:2} -W '7z bzip2 gzip swfc
+ tar wim xz zip' -- "${cur:2}" ) )
+ else
+ COMPREPLY=( $( compgen -P${cur:0:2} -W '7z apm arj bzip2 cab
+ chm cpio cramfs deb dmg elf fat flv gzip hfs iso lzh lzma
+ lzma86 macho mbr mslz mub nsis ntfs pe ppmd rar rpm
+ squashfs swf swfc tar udf vhd wim xar xz z zip' \
+ -- "${cur:2}" ) )
+ fi
return
;;
- -a*|-i*|-m*|-p*|-u*|-v*|-x*)
+ -m*=*|-p*|-u*|-v*)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $( compgen -W '-ai -ax -bd -i -m -o -p -r -scs -sfx -si
- -slt -so -ssc -t -u -v -w -x -y' -- "$cur" ) )
- [[ $COMPREPLY == -@(bd|sfx|si|slt|so|ssc|[rwy]) ]] || compopt -o nospace
+ COMPREPLY=( $( compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}=
+ -o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y' \
+ -- "$cur" ) )
+ [[ $COMPREPLY == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] ||
+ compopt -o nospace
return
fi
local args
_count_args =
if [[ $args -eq 2 ]]; then
_filedir_xspec unzip
- _filedir '@(7z|arj|bz2|cab|cpio|deb|gem|?(g)tar|?(t)[bg]z|tb?(z)2|rpm)'
+ [[ $mode == w ]] &&
+ _filedir '@(7z|bz2|swf|?(g)tar|?(t)[bglx]z|tb?(z)2|wim)' ||
+ _filedir '@(7z|arj|bz2|cab|chm|cpio|deb|dmg|flv|gem|img|iso|lz[ah]|lzma?(86)|pmd|[rx]ar|rpm|sw[fm]|?(g)tar|taz|?(t)[bglx]z|tb?(z)2|vhd|wim|Z)'
else
- _filedir
+ if [[ ${words[1]} == d ]]; then
+ local IFS=$'\n'
+ COMPREPLY=( $( compgen -W "$( printf '%s\n' $( 7z l ${words[2]} \
+ -slt 2>/dev/null | sed -n '/^Path =/s/^Path = \(.*\)$/\1/p' \
+ 2>/dev/null | tail -n+2 ) )" -- "$cur" ) )
+ compopt -o filenames
+ else
+ _filedir
+ fi
fi
} &&
complete -F _7z 7z 7za
@@ -23,12 +23,12 @@ _abook()
case $prev in
--informat)
COMPREPLY=( $( compgen -W "$(abook --formats | \
- sed -n -e 's/^\t\([a-z]*\).*/\1/p' -e '/^$/q')" -- "$cur" ) )
+ sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')" -- "$cur" ) )
return 0
;;
--outformat)
COMPREPLY=( $( compgen -W "$(abook --formats | \
- sed -n -e '/^$/,$s/^\t\([a-z]*\).*/\1/p')" -- "$cur" ) )
+ sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')" -- "$cur" ) )
return 0
;;
--infile)
@@ -26,7 +26,7 @@ _aptitude()
local special i
for (( i=0; i < ${#words[@]}-1; i++ )); do
- if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag|versions) ]]; then
+ if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full|safe)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag|versions) ]]; then
special=${words[i]}
fi
#exclude some mutually exclusive options
@@ -37,8 +37,8 @@ _aptitude()
if [[ -n "$special" ]]; then
case $special in
install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade| \
- download|show|changelog|why|why-not|build-dep|add-user-tag| \
- remove-user-tag|versions)
+ safe-upgrade|download|show|changelog|why|why-not|build-dep| \
+ add-user-tag|remove-user-tag|versions)
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
;;
@@ -56,7 +56,7 @@ _aptitude()
case $prev in
# don't complete anything if these options are found
- autoclean|clean|forget-new|search|safe-upgrade|upgrade|update|keep-all)
+ autoclean|clean|forget-new|search|upgrade|update|keep-all)
return 0
;;
-S)
@@ -25,9 +25,7 @@ _bzip2()
local IFS=$'\n' xspec="*.bz2"
if [[ "$prev" == --* ]]; then
- [[ "$prev" == --decompress || \
- "$prev" == --list || \
- "$prev" == --test ]] && xspec="!"$xspec
+ [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec
[[ "$prev" == --compress ]] && xspec=
elif [[ "$prev" == -* ]]; then
[[ "$prev" == -*[dt]* ]] && xspec="!"$xspec
@@ -22,8 +22,9 @@ _cppcheck()
cur="${cur##*,}"
split=true
fi
- COMPREPLY=( $( compgen -W 'all style performance portability
- information unusedFunction missingInclude' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W 'all warning style performance
+ portability information unusedFunction missingInclude' \
+ -- "$cur" ) )
$split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} )
return
;;
@@ -59,6 +60,10 @@ _cppcheck()
return
fi
;;
+ --library)
+ _filedir cfg
+ return
+ ;;
--xml-version)
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
return
@@ -3,7 +3,7 @@
_dictdata()
{
dict $host $port $1 2>/dev/null | sed -ne \
- 's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
+ 's/^['$'\t '']\{1,\}\([^ '$'\t'']*\).*$/\1/p'
}
_dict()
@@ -8,11 +8,11 @@ _comp_dpkg_installed_packages()
} || {
_comp_dpkg_installed_packages()
{
- command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
+ command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
half-configured" \
-Ee "^Essential: yes" | \
- command grep "Package: $1" | cut -d\ -f2
+ command grep "Package: $1" 2>/dev/null | cut -d\ -f2
}
}
@@ -24,11 +24,11 @@ _comp_dpkg_purgeable_packages()
} || {
_comp_dpkg_purgeable_packages()
{
- command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
+ command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
half-configured|config-files" \
-Ee "^Essential: yes" | \
- command grep "Package: $1" | cut -d\ -f2
+ command grep "Package: $1" 2>/dev/null | cut -d\ -f2
}
}
@@ -24,7 +24,12 @@ _export()
break
done
- [[ $cur == *=\$* ]] && { cur=${cur#*=}; _variables; } && return
+ if [[ $cur == *=* ]]; then
+ local ocur=$cur oprev=$prev
+ prev=${cur%%=*} cur=${cur#*=}
+ _variables && return
+ cur=$ocur prev=$oprev
+ fi
case $cur in
*=)
View
@@ -27,6 +27,9 @@ _gcc()
*77)
backend=f771
;;
+ *95)
+ backend=f951
+ ;;
*)
backend=cc1 # (near-)universal backend
;;
@@ -45,10 +48,20 @@ _gcc()
_filedir
fi
} &&
-complete -F _gcc gcc g++ g77 gcj gpc &&
+complete -F _gcc gcc g++ gfortran g77 g95 gcj gpc &&
{
- cc --version 2>/dev/null | grep -q GCC && complete -F _gcc cc || :
- c++ --version 2>/dev/null | grep -q GCC && complete -F _gcc c++ || :
+ cc --version 2>/dev/null | grep -q GCC || \
+ [[ $( _realcommand cc ) == *gcc* ]] && \
+ complete -F _gcc cc || complete -F _minimal cc
+ c++ --version 2>/dev/null | grep -q GCC || \
+ [[ $( _realcommand c++ ) == *g++* ]] && \
+ complete -F _gcc c++ || complete -F _minimal c++
+ f77 --version 2>/dev/null | grep -q GCC || \
+ [[ $( _realcommand f77 ) == *gfortran* ]] && \
+ complete -F _gcc f77 || complete -F _minimal f77
+ f95 --version 2>/dev/null | grep -q GCC || \
+ [[ $( _realcommand f95 ) == *gfortran* ]] && \
+ complete -F _gcc f95 || complete -F _minimal f95
}
# ex: ts=4 sw=4 et filetype=sh
Oops, something went wrong.

0 comments on commit 68adb8c

Please sign in to comment.