BASH=/bin/bash BASHOPTS=checkwinsize:cmdhist:expand_aliases:extglob:extquote:force_fignore:interactive_comments:progcomp:promptvars:sourcepath BASH_ALIASES=() BASH_ARGC=() BASH_ARGV=() BASH_CMDS=() BASH_COMPLETION=/etc/bash_completion BASH_COMPLETION_COMPAT_DIR=/etc/bash_completion.d BASH_COMPLETION_DIR=/etc/bash_completion.d BASH_LINENO=() BASH_SOURCE=() BASH_VERSINFO=([0]="4" [1]="2" [2]="10" [3]="1" [4]="release" [5]="i386-redhat-linux-gnu") BASH_VERSION='4.2.10(1)-release' COLORS=/etc/DIR_COLORS COLORTERM=gnome-terminal COLUMNS=80 DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-CBpTgi0178,guid=c581a2e3b6661fc7c869be980000004d DESKTOP_SESSION=gnome DIRSTACK=() DISPLAY=:0.0 EUID=500 GDMSESSION=gnome GDM_LANG=zh_CN.utf8 GNOME_DESKTOP_SESSION_ID=this-is-deprecated GNOME_KEYRING_CONTROL=/tmp/keyring-wGhKpK GNOME_KEYRING_PID=1302 GPG_AGENT_INFO=/tmp/keyring-wGhKpK/gpg:0:1 GROUPS=() G_BROKEN_FILENAMES=1 HISTCONTROL=ignoredups HISTFILE=/home/chuxin/.bash_history HISTFILESIZE=1000 HISTSIZE=1000 HOME=/home/chuxin HOSTNAME=chuxinbsn HOSTTYPE=i386 IFS=$' \t\n' IMSETTINGS_INTEGRATE_DESKTOP=yes IMSETTINGS_MODULE=IBus LANG=zh_CN.utf8 LESSOPEN='||/usr/bin/lesspipe.sh %s' LINES=24 LOGNAME=chuxin LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:' MACHTYPE=i386-redhat-linux-gnu MAIL=/var/spool/mail/chuxin MAILCHECK=60 OPTERR=1 OPTIND=1 ORBIT_SOCKETDIR=/tmp/orbit-chuxin OSTYPE=linux-gnu PATH=.:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/chuxin/.local/bin:/home/chuxin/bin PIPESTATUS=([0]="0") PPID=4589 PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' PS1='[\u@\h \W]\$ ' PS2='> ' PS4='+ ' PWD=/home/chuxin QT_IM_MODULE=xim SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/1312,unix/unix:/tmp/.ICE-unix/1312 SHELL=/bin/bash SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor SHLVL=2 SSH_AUTH_SOCK=/tmp/keyring-wGhKpK/ssh TERM=xterm UID=500 USER=chuxin USERNAME=chuxin WINDOWID=56623110 WINDOWPATH=1 XAUTHORITY=/var/run/gdm/auth-for-chuxin-jelf2j/database XDG_RUNTIME_DIR=/run/user/chuxin XDG_SESSION_COOKIE=7146ed264edb727a8ab183560000000c-1310340438.697031-615884051 XDG_SESSION_ID=1 XMODIFIERS=@im=ibus _=--color=auto __pkcon_commandlist=$'\n accept-eula\n get-roles\n get-depends\n get-details\n get-distro-upgrades\n get-files\n get-filters\n get-groups\n get-packages\n download\n get-requires\n get-time\n get-transactions\n get-update-detail\n get-updates\n get-categories\n install\n install-local\n refresh\n remove\n repo-disable\n repo-enable\n repo-list\n repo-set-data\n resolve\n search\n update\n upgrade-system\n ' _scp_path_esc='[][(){}<>",:;^&!$=?`|\\'\''[:space:]]' colors=/etc/DIR_COLORS __contains_word () { local word=$1; shift; for w in $*; do [[ $w = $word ]] && return 0; done; return 1 } __dconf () { local choices; case "${COMP_CWORD}" in 1) choices='help read list write update lock unlock watch ' ;; 2) case "${COMP_WORDS[1]}" in help) choices='help read list write update lock unlock watch ' ;; list) choices="$(dconf _complete / "${COMP_WORDS[2]}")" ;; read | list | write | lock | unlock | watch) choices="$(dconf _complete '' "${COMP_WORDS[2]}")" ;; esac ;; esac; local IFS=' '; COMPREPLY=($(compgen -W "${choices}" "${COMP_WORDS[$COMP_CWORD]}")) } __expand_tilde_by_ref () { if [ "${!1:0:1}" = "~" ]; then if [ "${!1}" != "${!1//\/}" ]; then eval $1="${!1/%\/*}"/'${!1#*/}'; else eval $1="${!1}"; fi; fi } __filter_units_by_property () { local property=$1 value=$2; shift; shift; local -a units=($*); local -a props=($(systemctl show --property "$property" -- ${units[*]} | grep -v ^$)); for ((i=0; $i < ${#units[*]}; i++)) do if [[ "${props[i]}" = "$property=$value" ]]; then echo "${units[i]}"; fi; done } __gdbus () { local IFS=' '; local cur=`_get_cword :`; local suggestions=$(gdbus complete "${COMP_LINE}" ${COMP_POINT}); COMPREPLY=($(compgen -W "$suggestions" -- "$cur")); case "$cur" in *:*) case "$COMP_WORDBREAKS" in *:*) local colon_word=${cur%${cur##*:}}; local i=${#COMPREPLY[*]}; while [ $((--i)) -ge 0 ]; do COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}; done ;; esac ;; esac } __get_active_units () { systemctl list-units --full | awk ' {print $1}' } __get_all_units () { systemctl list-units --full --all | awk ' {print $1}' } __get_cword_at_cursor_by_ref () { local cword words=(); __reassemble_comp_words_by_ref "$1" words cword; local i cur2; local cur="$COMP_LINE"; local index="$COMP_POINT"; for ((i = 0; i <= cword; ++i )) do while [[ "${#cur}" -ge ${#words[i]} && "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do cur="${cur:1}"; ((index--)); done; if [[ "$i" -lt "$cword" ]]; then local old_size="${#cur}"; cur="${cur#${words[i]}}"; local new_size="${#cur}"; index=$(( index - old_size + new_size )); fi; done; if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then cur2=${words[cword]}; else cur2=${cur:0:$index}; fi; local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "$cur2" } __get_failed_units () { systemctl list-units --full | awk '$3 == "failed" {print $1}' } __get_inactive_units () { systemctl list-units --full --all | awk '$3 == "inactive" {print $1}' } __gsettings () { local choices; case "${COMP_CWORD}" in 1) choices='help list-schemas list-relocatable-schemas list-keys list-children list-recursively get range set reset writable monitor' ;; 2) case "${COMP_WORDS[1]}" in help) choices='list-schemas list-relocatable-schemas list-keys list-children list-recursively get range set reset writable monitor' ;; list-keys | list-children | list-recursively) choices="$(gsettings list-schemas)"' '"$(gsettings list-relocatable-schemas | sed -e 's.$.:/.')" ;; get | range | set | reset | writable | monitor) choices="$(gsettings list-schemas | sed -e 's.$. .')"' '"$(gsettings list-relocatable-schemas | sed -e 's.$.:/.')" ;; esac ;; 3) case "${COMP_WORDS[1]}" in set) choices="$(gsettings list-keys ${COMP_WORDS[2]} 2> /dev/null | sed -e 's.$. .')" ;; get | range | reset | writable | monitor) choices="$(gsettings list-keys ${COMP_WORDS[2]} 2> /dev/null)" ;; esac ;; 4) case "${COMP_WORDS[1]}" in set) range=($(gsettings range ${COMP_WORDS[2]} ${COMP_WORDS[3]} 2> /dev/null)); case "${range[0]}" in enum) unset range[0] ;; *) unset range ;; esac; local IFS=' '; choices="${range[*]}" ;; esac ;; esac; local IFS=' '; COMPREPLY=($(compgen -W "${choices}" "${COMP_WORDS[$COMP_CWORD]}")) } __gvfs_multiple_uris () { local IFS=' '; local cur="${COMP_WORDS[COMP_CWORD]}"; COMPREPLY=($(compgen -W '$(gvfs-ls --show-completions "$cur")' -- "")); case "$cur" in *:*) case "$COMP_WORDBREAKS" in *:*) colon_prefix=$(echo $cur | sed 's/:[^:]*$/:/' ); COMPREPLY=${COMPREPLY##${colon_prefix}} ;; esac ;; esac } __linux_fstab_unescape () { eval $1="'${!1//\'/\047}'"; eval $1="'${!1/%\\/\\\\}'"; eval "$1=$'${!1}'" } __ltrim_colon_completions () { if [[ "$1" == *:* && ( ${BASH_VERSINFO[0]} -lt 4 || ( ${BASH_VERSINFO[0]} -ge 4 && "$COMP_WORDBREAKS" == *:* ) ) ]]; then local colon_word=${1%${1##*:}}; local i=${#COMPREPLY[*]}; while [ $((--i)) -ge 0 ]; do COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}; done; fi } __pkconcomp () { local all c s=' ' IFS=' '' '' '; local cur="${COMP_WORDS[COMP_CWORD]}"; if [ $# -gt 2 ]; then cur="$3"; fi; for c in $1; do case "$c$4" in *.) all="$all$c$4$s" ;; *) all="$all$c$4 $s" ;; esac; done; IFS=$s; COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur")); return } __reassemble_comp_words_by_ref () { local exclude i j ref; if [[ -n $1 ]]; then exclude="${1//[^$COMP_WORDBREAKS]}"; fi; eval $3=$COMP_CWORD; if [[ -n $exclude ]]; then for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)) do while [[ $i -gt 0 && -n ${COMP_WORDS[$i]} && ${COMP_WORDS[$i]//[^$exclude]} == ${COMP_WORDS[$i]} ]]; do [ $j -ge 2 ] && ((j--)); ref="$2[$j]"; eval $2[$j]=\${!ref}\${COMP_WORDS[i]}; [ $i = $COMP_CWORD ] && eval $3=$j; (( $i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2; done; ref="$2[$j]"; eval $2[$j]=\${!ref}\${COMP_WORDS[i]}; [[ $i == $COMP_CWORD ]] && eval $3=$j; done; else eval $2=\( \"\${COMP_WORDS[@]}\" \); fi } __udisks () { local IFS=' '; local cur="${COMP_WORDS[COMP_CWORD]}"; if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--show-info" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--inhibit-polling" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--mount" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--unmount" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--detach" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--eject" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--ata-smart-refresh" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--ata-smart-simulate" ]; then _filedir || return 0; else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--set-spindown" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else if [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--poll-for-media" ]; then COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur)); else COMPREPLY=($(IFS=: compgen -W "--dump:--inhibit-polling:--inhibit-all-polling:--enumerate:--enumerate-device-files:--monitor:--monitor-detail:--show-info:--help:--mount:--mount-fstype:--mount-options:--unmount:--unmount-options:--detach:--detach-options:--eject:--eject-options:--ata-smart-refresh:--ata-smart-wakeup:--ata-smart-simulate:--set-spindown:--set-spindown-all:--spindown-timeout:--poll-for-media" -- $cur)); fi; fi; fi; fi; fi; fi; fi; fi; fi; fi } _aclocal () { COMPREPLY=(); local cur prev split=false; _get_comp_words_by_ref cur prev; _split_longopt && split=true; case "$prev" in --help | --print-ac-dir | --version) return 0 ;; --acdir | -I) _filedir -d; return 0 ;; --output) _filedir; return 0 ;; --warnings | -W) local cats=(syntax unsupported); COMPREPLY=($( compgen -W '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" )); return 0 ;; esac; $split && return 0; _longopt $1 } _alias () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; case $COMP_LINE in *[^=]) COMPREPLY=($( compgen -A alias -- "$cur" )) ;; *=) COMPREPLY=("$( alias ${cur%=} 2>/dev/null | sed -e 's|^alias '"$cur"'\(.*\)$|\1|' )") ;; esac } _allowed_groups () { if _complete_as_root; then local IFS=' '; COMPREPLY=($( compgen -g -- "$1" )); else local IFS=' '; COMPREPLY=($( compgen -W "$( id -Gn 2>/dev/null || groups 2>/dev/null )" -- "$1" )); fi } _allowed_users () { if _complete_as_root; then local IFS=' '; COMPREPLY=($( compgen -u -- "${1:-$cur}" )); else local IFS=' '; COMPREPLY=($( compgen -W "$( id -un 2>/dev/null || whoami 2>/dev/null )" -- "${1:-$cur}" )); fi } _autoconf () { COMPREPLY=(); local cur prev split=false; _get_comp_words_by_ref cur prev; _split_longopt && split=true; case "$prev" in --help | -h | --version | -V | --trace | -t) return 0 ;; --output | -o) _filedir; return 0 ;; --warnings | -W) local cats=(cross obsolete syntax); COMPREPLY=($( compgen -W '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" )); return 0 ;; --prepend-include | -B | --include | -I) _filedir -d; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then _longopt $1; return; fi; _filedir '@(ac|in)' } _automake () { COMPREPLY=(); local cur prev split=false; _get_comp_words_by_ref cur prev; _split_longopt && split=true; case "$prev" in --help | --version) return 0 ;; --warnings | -W) local cats=(gnu obsolete override portability syntax unsupported); COMPREPLY=($( compgen -W '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" )); return 0 ;; --libdir) _filedir -d; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then _longopt $1; return; fi; _filedir } _autoreconf () { COMPREPLY=(); local cur prev split=false; _get_comp_words_by_ref cur prev; _split_longopt && split=true; case "$prev" in --help | -h | --version | -V) return 0 ;; --warnings | -W) local cats=(cross gnu obsolete override portability syntax unsupported); COMPREPLY=($( compgen -W '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" )); return 0 ;; --prepend-include | -B | --include | -I) _filedir -d; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then _longopt $1; return 0; fi; if [[ $1 == autoheader ]]; then _filedir '@(ac|in)'; else _filedir -d; fi } _autoscan () { COMPREPLY=(); local cur prev split=false; _get_comp_words_by_ref cur prev; _split_longopt && split=true; case "$prev" in --help | -h | --version | -V) return 0 ;; --prepend-include | -B | --include | -I) _filedir -d; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then _longopt $1; return 0; fi; if [[ $1 == autoupdate ]]; then _filedir '@(ac|in)'; else _filedir -d; fi } _available_interfaces () { local cmd; if [ "${1:-}" = -w ]; then cmd="iwconfig"; else if [ "${1:-}" = -a ]; then cmd="ifconfig"; else cmd="ifconfig -a"; fi; fi; COMPREPLY=($( eval PATH="$PATH:/sbin" $cmd 2>/dev/null | awk '/^[^ \t]/ { print $1 }' )); COMPREPLY=($( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" )) } _avctrl () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --quiet' -- "$cur" )); else _count_args; if [ $args -eq 1 ]; then COMPREPLY=($( compgen -W 'discover switch' -- "$cur" )); fi; fi } _badblocks () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -b | -c | -e | -d | -p | -t) return 0 ;; -i | -o) _filedir; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-b -c -e -d -f -i -n -o -p -s -t -v' -- "$cur" )); return 0; fi; cur=${cur:=/dev/}; _filedir } _bluetooth_adresses () { if [ -n "${COMP_BLUETOOTH_SCAN:-}" ]; then COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$( hcitool scan | awk '/^\t/{print $1}' )" -- "$cur" )); fi } _bluetooth_devices () { COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$( hcitool dev | awk '/^\t/{print $1}' )" -- "$cur" )) } _bluetooth_packet_types () { COMPREPLY=($( compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' -- "$cur" )) } _bluetooth_services () { COMPREPLY=($( compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG \ SAP NAP GN PANU HCRP HID CIP A2SRC A2SNK AVRCT AVRTG UDIUE \ UDITE SYNCML' -- "$cur" )) } _btdownload () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in --responsefile | --saveas) _filedir; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--max_uploads --keepalive_interval \ --download_slice_size --request_backlog --max_message_length \ --ip --minport --maxport --responsefile --url --saveas --timeout \ --timeout_check_interval --max_slice_length --max_rate_period \ --bind --upload_rate_fudge --display_interval --rerequest_interval \ --min_peers --http_timeout --max_initiate --max_allow_in \ --check_hashes --max_upload_rate --snub_time --spew \ --rarest_first_cutoff --min_uploads --report_hash_failures' -- "$cur" )); else _filedir; fi } _bzip2 () { local cur prev xspec helpopts; COMPREPLY=(); _get_comp_words_by_ref cur prev; helpopts=`_parse_help ${COMP_WORDS[0]}`; case $prev in -b | -h | --help | -p) return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" -- "$cur" )); return 0; fi; local IFS=' '; xspec="*.bz2"; if [[ "$prev" == --* ]]; then [[ "$prev" == --decompress || "$prev" == --list || "$prev" == --test ]] && xspec="!"$xspec; [[ "$prev" == --compress ]] && xspec=; else if [[ "$prev" == -* ]]; then [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec; [[ "$prev" == -*z* ]] && xspec=; fi; fi; _expand || return 0; _compopt_o_filenames; COMPREPLY=($( compgen -f -X "$xspec" -- "$cur" ) $( compgen -d -- "$cur" )) } _cancel () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; COMPREPLY=($( compgen -W "$( lpstat | cut -d' ' -f1 )" -- "$cur" )) } _cd () { local cur IFS=' ' i j k; _get_comp_words_by_ref cur; if [[ "$cur" == ?(\\)\$* ]]; then COMPREPLY=($( compgen -v -P '$' -- "${cur#?(\\)$}" )); return 0; fi; _compopt_o_filenames; if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then _filedir -d; return 0; fi; local -r mark_dirs=$(_rl_enabled mark-directories && echo y); local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y); for i in ${CDPATH//:/' '}; do k="${#COMPREPLY[@]}"; for j in $( compgen -d $i/$cur ); do if [[ ( -n $mark_symdirs && -h $j || -n $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then j="${j}/"; fi; COMPREPLY[k++]=${j#$i/}; done; done; _filedir -d; if [[ ${#COMPREPLY[@]} -eq 1 ]]; then i=${COMPREPLY[0]}; if [[ "$i" == "$cur" && $i != "*/" ]]; then COMPREPLY[0]="${i}/"; fi; fi; return 0 } _cd_devices () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}" )) } _cdrecord () { local cur prev i generic_options track_options track_mode; COMPREPLY=(); _get_comp_words_by_ref -n = cur prev; if [[ "$cur" == *=* ]]; then prev=${cur%%=*}; cur=${cur#*=}; case $prev in textfile | cuefile | msifile) compopt +o nospace &>/dev/null; _filedir ;; blank) compopt +o nospace &>/dev/null; COMPREPLY=($( compgen -W 'help all fast track unreserve trtail unclose session' -- "$cur" )) ;; driveropts) if [[ $cur == *=* ]]; then prev=${cur%%=*}; cur=${cur#*=}; case $prev in varirec) compopt +o nospace &>/dev/null; COMPREPLY=($( compgen -W "-2 -1 0 1 2" -- "$cur" )) ;; gigarec) compopt +o nospace &>/dev/null; COMPREPLY=($( compgen -W "0.6 0.7 0.8 1.0 1.2 1.3 1.4" -- "$cur" )) ;; tattoofile) compopt +o nospace &>/dev/null; _filedir ;; esac; else COMPREPLY=($( compgen -W 'burnfree noburnfree varirec= gigarec= audiomaster forcespeed noforcespeed speedread nospeedread singlesession nosinglesession hidecdr nohidecdr tattooinfo tattoofile=' -- "$cur" )); [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && compopt +o nospace &>/dev/null; fi ;; driver) compopt +o nospace &>/dev/null; COMPREPLY=($( compgen -W "$( $1 driver=help 2>&1 | awk 'NR > 1 { print $1 }' ) help" -- "$cur" )) ;; minbuf) compopt +o nospace &>/dev/null; COMPREPLY=($( compgen -W "$( seq 25 95 2>/dev/null )" -- "$cur" )) ;; esac; return 0; fi; generic_options=(-version -v -V -d -silent -force -immed -dummy -clone -dao -sao -tao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive -prcap -inq -scanbus --devices -reset -abort -overburn -ignsize -useinfo -packet -noclose -text debug= kdebug= minbuf= msifile= speed= blank= fs= ts= dev= gracetime= timeout= driver= driveropts= defpregap= pktsize= mcn= textfile= cuefile=); track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi -isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp -copy -nocopy -scms isrc= index= padsize= pregap= tsize=); track_mode=0; if [ $COMP_CWORD -gt 1 ]; then if [ -f "$prev" ]; then track_mode=1; else for ((i=0; i < ${#track_options[@]}; i++ )) do if [[ "${track_options[i]}" == "$prev" ]]; then track_mode=1; break; fi; done; fi; fi; _filedir; COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- "$cur" )); if [ $track_mode -eq 0 ]; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '${generic_options[@]}' -- "$cur" )); fi; [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && compopt +o nospace &>/dev/null } _chage () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -d | --lastday | -E | --expiredate | -h | --help | -I | --inactive | -m | --mindays | -M | --maxdays | -W | --warndays) return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--lastday --expiredate --help --inactive \ --list --mindays --maxdays --warndays' -- "$cur" )); return 0; fi; COMPREPLY=($( compgen -u -- "$cur" )) } _chgrp () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; cur=${cur//\\\\/}; _split_longopt && split=true; if [[ "$prev" == --reference ]]; then _filedir; return 0; fi; $split && return 0; if [[ "$cur" == -* ]]; then local w opts; for w in "${COMP_WORDS[@]}"; do [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break; done; COMPREPLY=($( compgen -W '-c -h -f -R -v --changes --dereference \ --no-dereference --silent --quiet --reference --recursive \ --verbose --help --version $opts' -- "$cur" )); return 0; fi; if [[ $COMP_CWORD -eq 1 && "$cur" != -* || "$prev" == -* ]]; then _allowed_groups; else _filedir || return 0; fi; return 0 } _chkconfig () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in --level=[1-6] | [1-6] | --list | --add | --del | --override) _services; return 0 ;; --level) COMPREPLY=($( compgen -W '1 2 3 4 5 6' -- "$cur" )); return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--list --add --del --override --level' -- "$cur" )); else if [[ $COMP_CWORD -eq 2 || $COMP_CWORD -eq 4 ]]; then COMPREPLY=($( compgen -W 'on off reset resetpriorities' -- "$cur" )); else _services; fi; fi } _chown () { local cur prev split=false; _get_comp_words_by_ref -n : cur prev; _split_longopt && split=true; case "$prev" in --from) _usergroup; return 0 ;; --reference) _filedir; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then local w opts; for w in "${COMP_WORDS[@]}"; do [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break; done; COMPREPLY=($( compgen -W '-c -h -f -R -v --changes --dereference \ --no-dereference --from --silent --quiet --reference --recursive \ --verbose --help --version $opts' -- "$cur" )); else local args; _count_args :; if [[ $args == 1 ]]; then _usergroup -u; else _filedir; fi; fi } _chpasswd () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -c | --crypt) COMPREPLY=($( compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur" )); return 0 ;; -s | --sha-rounds) return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--crypt-method --encrypted \ --help --md5 --sha-rounds' -- "$cur" )); return 0; fi } _chsh () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in --list-shells | --help | -v | --version) return 0 ;; -s | --shell) _shells; return 0 ;; esac; if [[ "$cur" == -* && "$( uname -s )" == @(Linux|GNU|GNU/*) ]]; then COMPREPLY=($( compgen -W '--shell --list-shells --help --version' -- "$cur" )); else COMPREPLY=($( compgen -u -- "$cur" )); fi; return 0 } _ciptool () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -i) _bluetooth_devices; _bluetooth_adresses; return 0 ;; esac; _get_first_arg; if [ -z $arg ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help -i' -- "$cur" )); else COMPREPLY=($( compgen -W 'show search connect release \ loopback' -- "$cur" )); fi; else case $arg in connect | release | loopback) _count_args; if [ $args -eq 2 ]; then _bluetooth_adresses; fi ;; esac; fi } _command () { local offset i; offset=1; for ((i=1; i <= COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" != -* ]]; then offset=$i; break; fi; done; _command_offset $offset } _command_offset () { local cur func cline cspec noglob cmd i char_offset word_offset _COMMAND_FUNC _COMMAND_FUNC_ARGS; word_offset=$1; 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 )); 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=(); _get_comp_words_by_ref cur; if [[ $COMP_CWORD -eq 0 ]]; then _compopt_o_filenames; COMPREPLY=($( compgen -c -- "$cur" )); else cmd=${COMP_WORDS[0]}; if complete -p ${cmd##*/} &>/dev/null; then cspec=$( complete -p ${cmd##*/} ); if [ "${cspec#* -F }" != "$cspec" ]; then func=${cspec#*-F }; func=${func%% *}; if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"; else $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"; fi; if [ "${cspec#*-o }" != "$cspec" ]; then cspec=${cspec#*-o }; cspec=${cspec%% *}; if [[ "$cspec" != @(dir|file)names ]]; then COMPREPLY=("${COMPREPLY[@]//\\\\:/:}"); else _compopt_o_filenames; fi; fi; else if [ -n "$cspec" ]; then cspec=${cspec#complete}; cspec=${cspec%%${cmd##*/}}; COMPREPLY=($( eval compgen "$cspec" -- "$cur" )); fi; fi; else if [ ${#COMPREPLY[@]} -eq 0 ]; then _filedir; fi; fi; fi } _complete () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -o) COMPREPLY=($( compgen -W 'bashdefault default dirnames filenames \ nospace plusdirs' -- "$cur" )); return 0 ;; -A) COMPREPLY=($( compgen -W 'alias arrayvar binding builtin command \ directory disabled enabled export file function group \ helptopic hostname job keyword running service setopt shopt \ signal stopped user variable' -- "$cur" )); return 0 ;; -C) COMPREPLY=($( compgen -A command -- "$cur" )); return 0 ;; -F) COMPREPLY=($( compgen -A function -- "$cur" )); return 0 ;; -p | -r) COMPREPLY=($( complete -p | sed -e 's|.* ||' )); COMPREPLY=($( compgen -W '${COMPREPLY[@]}' -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then local opts="-a -b -c -d -e -f -g -j -k -o -s -u -v -A -G -W -P -S -X"; [[ $1 != compgen ]] && opts="$opts -F -C"; COMPREPLY=($( compgen -W "$opts" -- "$cur" )); else COMPREPLY=($( compgen -A command -- "$cur" )); fi } _complete_as_root () { [[ $EUID -eq 0 || -n ${root_command:-} ]] } _compopt_o_filenames () { type compopt &>/dev/null && compopt -o filenames 2> /dev/null || compgen -f /non-existing-dir/ > /dev/null } _configure () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in --*prefix | --*dir) _filedir -d ;; esac; $split && return 0; [[ "$cur" != -* ]] && return 0; if [ -n "$COMP_CONFIGURE_HINTS" ]; then COMPREPLY=($( compgen -W "$( $1 --help 2>&1 | awk '/^ --[A-Za-z]/ { print $1; \ if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" -- "$cur" )); else COMPREPLY=($( compgen -W "$( $1 --help 2>&1 | awk '/^ --[A-Za-z]/ { print $1; \ if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' )" -- "$cur" )); fi } _configured_interfaces () { if [ -f /etc/debian_version ]; then COMPREPLY=($( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces )" -- "$cur" )); else if [ -f /etc/SuSE-release ]; then COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network/ifcfg-* | sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" )); else if [ -f /etc/pld-release ]; then COMPREPLY=($( compgen -W "$( command ls -B /etc/sysconfig/interfaces | sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" )); else COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network-scripts/ifcfg-* | sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" )); fi; fi; fi } _count_args () { local i cword words; __reassemble_comp_words_by_ref "$1" words cword; args=1; for i in "${words[@]:1:cword-1}"; do [[ "$i" != -* ]] && args=$(($args+1)); done } _cpio () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev; _split_longopt && split=true; case $prev in -H | --format) _cpio_format; return 0 ;; -E | -F | -I | --file | --pattern-file) _filedir; return 0 ;; -R | --owner) _usergroup; return 0 ;; --rsh-command) _compopt_o_filenames; COMPREPLY=($( compgen -c -- "$cur" )); return 0 ;; esac; $split && return 0; if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=($( compgen -W '-o --create -i --extract -p --pass-through \ -? --help --license --usage --version' -- "$cur" )); else case ${COMP_WORDS[1]} in -o | --create) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-0 -a -c -v -A -B\ -L -V -C -H -M -O -F --file --format\ --message --null --reset-access-time\ --verbose --dot --append --block-size\ --dereference --io-size --quiet\ --force-local --rsh-command --help\ --version' -- "$cur" )); fi ;; -i | --extract) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-b -c -d -f -m -n -r\ -t -s -u -v -B -S -V -C -E -H -M -R -I\ -F --file --make-directories\ --nonmatching\ --preserve-modification-time\ --numeric-uid-gid --rename -t --list\ --swap-bytes --swap --dot\ --unconditional --verbose --block-size\ --swap-halfwords --io-size\ --pattern-file --format --owner\ --no-preserve-owner --message\ --force-local --no-absolute-filenames\ --sparse --only-verify-crc --quiet\ --rsh-command --help\ --to-stdout \ --version' -- "$cur" )); fi ;; -p | --pass-through) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-0 -a -d -l -m -u -v\ -L -V -R --null --reset-access-time\ --make-directories --link --quiet\ --preserve-modification-time\ --unconditional --verbose --dot\ --dereference --owner\ --no-preserve-owner --sparse --help\ --version' -- "$cur" )); else _filedir -d; fi ;; esac; fi } _cpio_format () { COMPREPLY=($( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur" )) } _crontab () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -u) _allowed_users; return 0 ;; esac; local i opts=" -u -l -r -e"; [ "$(uname -s)" = Linux ] && opts="$opts -i"; [ -e /etc/selinux ] && opts="$opts -s"; for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ )) do case "${COMP_WORDS[i]}" in -l) opts=${opts// -l -r -e/}; opts=${opts// -i/}; opts=${opts// -s/} ;; -e) opts=${opts// -l -r -e/}; opts=${opts// -i/} ;; -r) opts=${opts// -l -r -e/} ;; -u) opts=${opts// -u/}; opts=${opts// -i/} ;; -i | -s) opts=${opts// ${COMP_WORDS[i]}/} ;; esac; done; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '$opts' -- "$cur" )); return 0; fi; [[ "${COMP_LINE}" == *\ -@(l|r|e)* ]] || _filedir } _cryptsetup () { local cur prev arg; COMPREPLY=(); cur=`_get_cword`; prev=`_get_pword`; case $prev in --key-file | --master-key-file | --header-backup-file | -d) _filedir; return 0 ;; esac; _get_first_arg; if [ -z $arg ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--hash --cipher --verify-passphrase \ --key-file --master-key-file --key-slot --key-size --size \ --offset --skip --readonly --iter-time --batch-mode --timeout \ --tries --align-payload --version' -- "$cur" )); else COMPREPLY=($( compgen -W 'create remove status resize luksFormat \ luksOpen luksClose luksSuspend luksResume luksAddKey \ luksRemoveKey luksKillSlot luksDelKey luksUUID isLuks \ luksDump luksHeaderBackup luksHeaderRestore' -- "$cur" )); fi; else _count_args; case $arg in create) case $args in 2) _cryptsetup_name ;; 3) _cryptsetup_device ;; esac ;; remove | status | resize | luksClose | luksSuspend | luksResume) case $args in 2) _cryptsetup_name ;; esac ;; luksFormat | luksAddKey | luksRemoveKey) case $args in 2) _cryptsetup_device ;; 3) _filedir ;; esac ;; luksOpen) case $args in 2) _cryptsetup_device ;; 3) _cryptsetup_name ;; esac ;; luksKillSlot | luksDelKey | luksUUID | isLuks | luksDump) case $args in 2) _cryptsetup_device ;; esac ;; luksHeaderBackup | luksHeaderRestore) case $args in 2) _cryptsetup_device ;; 3) COMPREPLY=('--header-backup-file') ;; esac ;; esac; fi; return 0 } _cryptsetup_device () { cur=${cur:=/dev/}; _filedir } _cryptsetup_name () { COMPREPLY=($( compgen -X control -W '$( command ls /dev/mapper )' -- "$cur" )) } _dd () { local cur; COMPREPLY=(); _get_comp_words_by_ref -n = cur; case $cur in if=* | of=*) cur=${cur#*=}; _filedir; return 0 ;; conv=*) cur=${cur#*=}; COMPREPLY=($( compgen -W 'ascii ebcdic ibm block unblock lcase notrunc ucase swab noerror sync' -- "$cur" )); return 0 ;; esac; _expand || return 0; COMPREPLY=($( compgen -W '--help --version' -- "$cur" ) $( compgen -W 'bs cbs conv count ibs if obs of seek skip' -S '=' -- "$cur" )) } _dfutool () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -d | --device) _bluetooth_devices; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --device' -- "$cur" )); else _count_args; case $args in 1) COMPREPLY=($( compgen -W 'verify modify \ upgrade archive' -- "$cur" )) ;; 2) _filedir ;; esac; fi } _dhclient () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -cf | -lf | -pf | -sf) _filedir; return 0 ;; -s) _known_hosts_real "$cur"; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-p -d -q -1 -r -lf -pf \ -cf -sf -s -g -n -nw -w' -- "$cur" )); else _available_interfaces; fi } _dumpe2fs () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -o | -V) return 0 ;; -i) _filedir; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-b -o -f -h -i -x -V' -- "$cur" )); return 0; fi; cur=${cur:=/dev/}; _filedir } _dvd_devices () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}" )) } _e2freefrag () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -c | -h) return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-c -h' -- "$cur" )); return 0; fi; cur=${cur:=/dev/}; _filedir } _e2label () { COMPREPLY=(); local cur cword; _get_comp_words_by_ref cur cword; if [ $cword -eq 1 ]; then cur=${cur:=/dev/}; _filedir; fi } _edquota () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --format) _quota_formats; return 0 ;; -f | --filesystem) _filesystems; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-r --remote -m --no-mixed-pathnames \ -g --group -u --user -p --prototype -F --format -f --filesystem \ -t --edit-period -T --edit-times' -- "$cur" )); else _user_or_group; fi } _ether_wake () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref -n : cur prev; case $prev in -i) _available_interfaces; return 0 ;; -p) return 0 ;; esac; if [[ $cur == -* ]]; then COMPREPLY=($( compgen -W '-b -D -i -p -V' -- "$cur" )); return 0; fi; _mac_addresses } _expand () { if [[ "$cur" == \~*/* ]]; then eval cur=$cur; else if [[ "$cur" == \~* ]]; then cur=${cur#\~}; COMPREPLY=($( compgen -P '~' -u "$cur" )); [ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]}; return ${#COMPREPLY[@]}; fi; fi } _export () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; case $COMP_LINE in *=\$*) COMPREPLY=($( compgen -v -P '$' -- "${cur#*=\$}" )) ;; *[^=]) COMPREPLY=($( compgen -v -S '=' -- "$cur" )) ;; *=) COMPREPLY=("$( eval echo -n \"$`echo ${cur%=}`\" | ( echo -n \' sed -e 's/'\''/'\''\\\'\'''\''/g' echo -n \' ) )") ;; esac } _faillog () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -h | --help | -l | --lock-time | -m | --maximum | -t | --time) return 0 ;; -u | --user) COMPREPLY=($( compgen -u -- "$cur" )); return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--all --help --lock-time \ --maximum --reset --time --user' -- "$cur" )); return 0; fi } _filedir () { local i IFS=' ' xspec; _tilde "$cur" || return 0; local -a toks; local quoted tmp; _quote_readline_by_ref "$cur" quoted; toks=(${toks[@]-} $( compgen -d -- "$quoted" | { while read -r tmp; do printf '%s\n' $tmp done } )); if [[ "$1" != -d ]]; then [[ ${BASH_VERSINFO[0]} -ge 4 ]] && xspec=${1:+"!*.@($1|${1^^})"} || xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}; toks=(${toks[@]-} $( compgen -f -X "$xspec" -- $quoted)); fi; [ ${#toks[@]} -ne 0 ] && _compopt_o_filenames; COMPREPLY=("${COMPREPLY[@]}" "${toks[@]}") } _filedir_xspec () { local IFS cur xspec; IFS=' '; COMPREPLY=(); _get_comp_words_by_ref cur; _expand || return 0; xspec=$( awk "/^complete[ \t]+.*[ \t]${1##*/}([ \t]|\$)/ { print \$0; exit }" "$BASH_COMPLETION" ); xspec=${xspec#*-X }; xspec=${xspec%% *}; local -a toks; local tmp; toks=(${toks[@]-} $( compgen -d -- "$(quote_readline "$cur")" | { while read -r tmp; do # see long TODO comment in _filedir() --David printf '%s\n' $tmp done } )); eval xspec="${xspec}"; local matchop=!; if [[ $xspec == !* ]]; then xspec=${xspec#!}; matchop=@; fi; [[ ${BASH_VERSINFO[0]} -ge 4 ]] && xspec="$matchop($xspec|${xspec^^})" || xspec="$matchop($xspec|$(printf %s $xspec | tr '[:lower:]' '[:upper:]'))"; toks=(${toks[@]-} $( eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | { while read -r tmp; do [ -n $tmp ] && printf '%s\n' $tmp done } )); [ ${#toks[@]} -ne 0 ] && _compopt_o_filenames; COMPREPLY=("${toks[@]}") } _filefrag () { COMPREPLY=(); local cur; _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-B -b -s -v -x' -- "$cur" )); return 0; fi; _filedir } _filesystems () { COMPREPLY=($( compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" -- "$cur" )) } _find () { local cur prev i exprfound onlyonce; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -maxdepth | -mindepth) COMPREPLY=($( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" )); return 0 ;; -newer | -anewer | -cnewer | -fls | -fprint | -fprint0 | -fprintf | -name | -iname | -lname | -ilname | -wholename | -iwholename | -samefile) _filedir; return 0 ;; -fstype) _fstypes; if [[ "$( uname -s )" == *BSD ]]; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -W 'local rdonly' -- "$cur" )); fi; return 0 ;; -gid) _gids; return 0 ;; -group) COMPREPLY=($( compgen -g -- "$cur" 2>/dev/null)); return 0 ;; -xtype | -type) COMPREPLY=($( compgen -W 'b c d p f l s' -- "$cur" )); return 0 ;; -uid) _uids; return 0 ;; -user) COMPREPLY=($( compgen -u -- "$cur" )); return 0 ;; -exec | -execdir | -ok | -okdir) COMP_WORDS=(COMP_WORDS[0] "$cur"); COMP_CWORD=1; _command; return 0 ;; -[acm]min | -[acm]time | -iname | -lname | -wholename | -iwholename | -lwholename | -ilwholename | -inum | -path | -ipath | -regex | -iregex | -links | -perm | -size | -used | -printf | -context) return 0 ;; -regextype) COMPREPLY=($( compgen -W 'emacs posix-awk posix-basic \ posix-egrep posix-extended' -- "$cur" )); return 0 ;; esac; _expand || return 0; for i in ${COMP_WORDS[@]}; do [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break; done; if [[ "$exprfound" != 1 && "$cur" != [-\(\),\!]* ]]; then _filedir -d; return 0; fi; COMPREPLY=($( compgen -W '-daystart -depth -follow -help \ -ignore_readdir_race -maxdepth -mindepth -mindepth -mount \ -noignore_readdir_race -noleaf -regextype -version -warn -nowarn \ -xdev \ -amin -anewer -atime -cmin -cnewer -ctime -empty -executable -false \ -fstype -gid -group -ilname -iname -inum -ipath -iregex -iwholename \ -links -lname -mmin -mtime -name -newer -nogroup -nouser -path -perm \ -readable -regex -samefile -size -true -type -uid -used -user \ -wholename -writable -xtype -context \ -delete -exec -execdir -fls -fprint -fprint0 -fprintf -ls -ok -okdir \ -print -print0 -printf -prune -quit' -- "$cur" )); onlyonce=' -daystart -depth -follow -help -ignore_readdir_race -maxdepth \ -mindepth -mount -noignore_readdir_race -noleaf -nowarn -regextype \ -version -warn -xdev '; COMPREPLY=($( (while read -d ' ' i; do [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] && continue # flatten array with spaces on either side, # otherwise we cannot grep on word boundaries of # first and last word COMPREPLY=" ${COMPREPLY[@]} " # remove word from list of completions COMPREPLY=( ${COMPREPLY/ ${i%% *} / } ) done printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}" )); _filedir; return 0 } _fstypes () { local fss; if [ -e /proc/filesystems ]; then fss="$( cut -d' ' -f2 /proc/filesystems ) $( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )"; else fss="$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null ) $( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null ) $( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null ) $( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null ) $( [ -d /etc/fs ] && command ls /etc/fs )"; fi; [ -n "$fss" ] && COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$fss" -- "$cur" )) } _function () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; if [[ $1 == @(declare|typeset) ]]; then if [ "$prev" = -f ]; then COMPREPLY=($( compgen -A function -- "$cur" )); else if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a -f -F -i -r -x -p' -- "$cur" )); fi; fi; else if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=($( compgen -A function -- "$cur" )); else COMPREPLY=("() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )"); fi; fi } _fusermount () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -h | -V | -o) return 0 ;; -u) COMPREPLY=($( compgen -W "$( awk '{ if ($3 ~ /^fuse\./) print $2 }' /etc/mtab 2>/dev/null )" -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-h -V -o -u -q -z' -- "$cur" )); else _filedir -d; fi } _gcc () { local cur cc backend; COMPREPLY=(); _get_comp_words_by_ref cur; _expand || return 0; case $1 in gcj) backend=jc1 ;; gpc) backend=gpc1 ;; *77) backend=f771 ;; *) backend=cc1 ;; esac; if [[ "$cur" == -* ]]; then cc=$( $1 -print-prog-name=$backend ); COMPREPLY=($( compgen -W "$( $cc --help 2>/dev/null | tr '\t' ' ' | sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | sort -u )" -- "$cur" )); else _filedir; fi } _gdb () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; if [ $COMP_CWORD -eq 1 ]; then local IFS; _compopt_o_filenames; if [[ "$cur" == */* ]]; then IFS=' '; COMPREPLY=($( PATH="$PATH:." compgen -d -c -- "$cur" )); else IFS=":"; local path_array=($( sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" )); IFS=' '; COMPREPLY=($( compgen -d -W '$(find "${path_array[@]}" . \ -mindepth 1 -maxdepth 1 -not -type d -executable \ -printf "%f\\n" 2>/dev/null)' -- "$cur" )); fi; else if [ $COMP_CWORD -eq 2 ]; then prev=${prev##*/}; COMPREPLY=($( compgen -fW "$( command ps axo comm,pid | awk '{if ($1 ~ /^'"$prev"'/) print $2}' )" -- "$cur" )); fi; fi } _gendiff () { COMPREPLY=(); local cur prev cword; _get_comp_words_by_ref cur prev cword; if [[ $cword -eq 1 ]]; then _filedir -d; else if [[ $prev == *\> ]]; then _filedir; fi; fi } _get_comp_words_by_ref () { local exclude flag i OPTIND=1; local cur cword words=(); local upargs=() upvars=() vcur vcword vprev vwords; while getopts "c:i:n:p:w:" flag "$@"; do case $flag in c) vcur=$OPTARG ;; i) vcword=$OPTARG ;; n) exclude=$OPTARG ;; p) vprev=$OPTARG ;; w) vwords=$OPTARG ;; esac; done; while [[ $# -ge $OPTIND ]]; do case ${!OPTIND} in cur) vcur=cur ;; prev) vprev=prev ;; cword) vcword=cword ;; words) vwords=words ;; *) echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" 1>&2; return 1 ;; esac; let "OPTIND += 1"; done; __get_cword_at_cursor_by_ref "$exclude" words cword cur; [[ -n $vcur ]] && { upvars+=("$vcur"); upargs+=(-v $vcur "$cur") }; [[ -n $vcword ]] && { upvars+=("$vcword"); upargs+=(-v $vcword "$cword") }; [[ -n $vprev ]] && { upvars+=("$vprev"); upargs+=(-v $vprev "${words[cword - 1]}") }; [[ -n $vwords ]] && { upvars+=("$vwords"); upargs+=(-a${#words[@]} $vwords "${words[@]}") }; (( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}" } _get_cword () { local LC_CTYPE=C; local cword words; __reassemble_comp_words_by_ref "$1" words cword; if [[ -n ${2//[^0-9]/} ]]; then printf "%s" "${words[cword-$2]}"; else if [[ "${#words[cword]}" -eq 0 || "$COMP_POINT" == "${#COMP_LINE}" ]]; then printf "%s" "${words[cword]}"; else local i; local cur="$COMP_LINE"; local index="$COMP_POINT"; for ((i = 0; i <= cword; ++i )) do while [[ "${#cur}" -ge ${#words[i]} && "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do cur="${cur:1}"; ((index--)); done; if [[ "$i" -lt "$cword" ]]; then local old_size="${#cur}"; cur="${cur#${words[i]}}"; local new_size="${#cur}"; index=$(( index - old_size + new_size )); fi; done; if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then printf "%s" "${words[cword]}"; else printf "%s" "${cur:0:$index}"; fi; fi; fi } _get_first_arg () { local i; arg=; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" != -* ]]; then arg=${COMP_WORDS[i]}; break; fi; done } _get_pword () { if [ $COMP_CWORD -ge 1 ]; then _get_cword "${@:-}" 1; fi } _getent () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in passwd) COMPREPLY=($( compgen -u "$cur" )); return 0 ;; group) COMPREPLY=($( compgen -g "$cur" )); return 0 ;; services) COMPREPLY=($( compgen -s "$cur" )); return 0 ;; hosts) COMPREPLY=($( compgen -A hostname "$cur" )); return 0 ;; protocols | networks | ahosts | ahostsv4 | ahostsv6 | rpc) COMPREPLY=($( compgen -W "$( getent "$prev" | awk '{ print $1 }' )" -- "$cur" )); return 0 ;; aliases | shadow) COMPREPLY=($( compgen -W "$( getent "$prev" | cut -d: -f1 )" -- "$cur" )); return 0 ;; esac; if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=($( compgen -W 'passwd group hosts services protocols \ networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc \ shadow' -- "$cur" )); fi } _gids () { if type getent &>/dev/null; then COMPREPLY=($( compgen -W '$( getent group | cut -d: -f3 )' -- "$cur" )); else if type perl &>/dev/null; then COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- "$cur" )); else COMPREPLY=($( compgen -W '$( cut -d: -f3 /etc/group )' -- "$cur" )); fi; fi } _gpasswd () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -a | -d | -A | -M) COMPREPLY=($( compgen -u -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a -d -r -R -A -M' -- "$cur" )); return 0; fi; COMPREPLY=($( compgen -g -- "$cur" )) } _gpg () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -s | --sign | --clearsign | --decrypt-files | --load-extension) _filedir; return 0 ;; --export | --sign-key | --lsignkey | --nrsignkey | --nrlsignkey | --editkey) COMPREPLY=($( compgen -W "$( gpg --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 | sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" )); if [ -e ~/.gnupg/gpg.conf ]; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf )" -- "$cur")); fi; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '$(gpg --dump-options)' -- "$cur" )); fi } _gpg2 () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in --homedir) _filedir -d; return 0 ;; -s | --sign | --clearsign | --options | --decrypt) _filedir; return 0 ;; --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key) COMPREPLY=($( compgen -W "$( gpg2 --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 | sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" )); if [ -e ~/.gnupg/gpg.conf ]; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf)" -- "$cur")); fi; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '$(gpg2 --dump-options)' -- "$cur" )); fi } _groupadd () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -g | --gid | -K | --key | -p | --password) return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--force --gid --help \ --key --non-unique --password --system' -- "$cur" )); return 0; fi } _groupmems () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -a | -d) COMPREPLY=($( compgen -u -- "$cur" )); return 0 ;; -g) COMPREPLY=($( compgen -g -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a -d -p -g -l' -- "$cur" )); return 0; fi } _groupmod () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -g | --gid | -h | --help | -n | --new-name | -p | --password) return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--gid --help --new-name \ --non-unique --password' -- "$cur" )); return 0; fi; COMPREPLY=($( compgen -g -- "$cur" )) } _growisofs () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -version | -speed) return 0 ;; -Z | -M) compopt -o nospace &>/dev/null; _dvd_devices; return 0 ;; /?(r)dev/*) if [[ $cur == =* ]]; then cur="${cur#=}"; _filedir; return 0; fi ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-dvd-compat -overburn -speed= -Z -M' -- "$cur" )); [[ ${COMPREPLY[@]} == *= ]] && compopt -o nospace &>/dev/null; return 0; fi; _filedir } _grpck () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-r -s' -- "$cur" )); return 0; fi; _filedir } _gzip () { local cur prev xspec helpopts; COMPREPLY=(); _get_comp_words_by_ref cur prev; helpopts=`_parse_help ${COMP_WORDS[0]}`; case $prev in -b | --blocksize | -p | --processes | -S | --suffix | -h | --help | -V | --version) return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$helpopts -1 -2 -3 -4 -5 -6 -7 -8 -9" -- "$cur" )); return 0; fi; local IFS=' '; xspec="*.@(gz|t[ag]z)"; if [[ "$prev" == --* ]]; then [[ "$prev" == --decompress || "$prev" == --list || "$prev" == --test ]] && xspec="!"$xspec; [[ "$prev" == --force ]] && xspec=; else if [[ "$prev" == -* ]]; then [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec; [[ "$prev" == -*f* ]] && xspec=; else if [[ "$prev" == '>' || "$prev" == '>>' ]]; then xspec=; else if [ "$prev" = '<' ]; then xspec=; fi; fi; fi; fi; _expand || return 0; _compopt_o_filenames; COMPREPLY=($( compgen -f -X "$xspec" -- "$cur" ) $( compgen -d -- "$cur" )) } _hciattach () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-n -p -t -b -s -l' -- "$cur" )); else _count_args; case $args in 1) COMPREPLY=($( printf '%s\n' /dev/tty* )); COMPREPLY=($( compgen -W '${COMPREPLY[@]} \ ${COMPREPLY[@]#/dev/}' -- "$cur" )) ;; 2) COMPREPLY=($( compgen -W 'any ericsson digi \ xircom csr bboxes swave bcsp 0x0105 \ 0x080a 0x0160 0x0002' -- "$cur" )) ;; 3) COMPREPLY=($( compgen -W '9600 19200 38400 \ 57600 115200 230400 460800 921600' -- "$cur" )) ;; 4) COMPREPLY=($( compgen -W 'flow noflow' -- "$cur" )) ;; 5) _bluetooth_adresses ;; esac; fi } _hciconfig () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; _get_first_arg; if [ -z $arg ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --all' -- "$cur" )); else COMPREPLY=($( compgen -W 'up down reset rstat auth \ noauth encrypt noencrypt secmgr nosecmgr \ piscan noscan iscan pscan ptype name class \ voice iac inqmode inqdata inqtype inqparams \ pageparms pageto afhmode aclmtu scomtu putkey \ delkey commands features version revision lm' -- "$cur" )); fi; else case $arg in putkey | delkey) _count_args; if [ $args -eq 2 ]; then _bluetooth_adresses; fi ;; lm) _count_args; if [ $args -eq 2 ]; then COMPREPLY=($( compgen -W 'MASTER \ SLAVE NONE ACCEPT' -- "$cur" )); fi ;; ptype) _count_args; if [ $args -eq 2 ]; then _bluetooth_packet_types; fi ;; esac; fi } _hcitool () { local cur prev split=false arg; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -i) _bluetooth_devices; return 0 ;; --role) COMPREPLY=($( compgen -W 'm s' -- "$cur" )); return 0 ;; --pkt-type) _bluetooth_packet_types; return 0 ;; esac; $split && return 0; _get_first_arg; if [ -z $arg ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help -i' -- "$cur" )); else COMPREPLY=($( compgen -W 'dev inq scan name info \ spinq epinq cmd con cc dc sr cpt rssi lq tpl \ afh lst auth enc key clkoff clock' -- "$cur" )); fi; else case $arg in name | info | dc | rssi | lq | afh | auth | key | clkoff | lst) _count_args; if [ $args -eq 2 ]; then _bluetooth_adresses; fi ;; cc) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--role --pkt-type' -- "$cur" )); else _count_args; if [ $args -eq 2 ]; then _bluetooth_adresses; fi; fi ;; sr) _count_args; if [ $args -eq 2 ]; then _bluetooth_adresses; else COMPREPLY=($( compgen -W 'master slave' -- "$cur" )); fi ;; cpt) _count_args; if [ $args -eq 2 ]; then _bluetooth_adresses; else _bluetooth_packet_types; fi ;; tpl | enc | clock) _count_args; if [ $args -eq 2 ]; then _bluetooth_adresses; else COMPREPLY=($( compgen -W '0 1' -- "$cur" )); fi ;; esac; fi } _hid2hci () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --quiet -0 --tohci -1 \ --tohid' -- "$cur" )); fi } _iconv () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -'?' | --help | --usage | -V | --version | --unicode-subst | --byte-subst | --widechar-subst) return 0 ;; -f | --from-code | -t | --to-code) COMPREPLY=($( compgen -W '$( iconv -l | \ sed -e "s@/*\$@@" -e "s/[,()]//g" )' -- "$cur" )); return 0 ;; -o | --output) _filedir; return 0 ;; esac; $split && return 0; if [[ "$cur" = -* ]]; then COMPREPLY=($( compgen -W '--from-code --to-code --list -c --unicode-subst --byte-subst --widechar-subst --output --silent --verbose --help --usage --version' -- "$cur" )); return 0; fi } _id () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a -g --group -G --groups -n --name\ -r --real -u --user --help --version' -- "$cur" )); else COMPREPLY=($( compgen -u "$cur" )); fi } _ifupdown () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [ $COMP_CWORD -eq 1 ]; then _configured_interfaces; COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")); fi; return 0 } _info () { local cur i infopath; COMPREPLY=(); _get_comp_words_by_ref cur; _expand || return 0; if [[ "$cur" == */* ]]; then _filedir; return 0; fi; infopath='/usr/share/info'; if [ "${INFOPATH: -1:1}" == ':' ]; then infopath=${INFOPATH}${infopath}; else if [ ${INFOPATH:+set} ]; then infopath=$INFOPATH; fi; fi; infopath=$infopath:; if [ -n "$cur" ]; then infopath="${infopath//://$cur* }"; else infopath="${infopath//:// }"; fi; COMPREPLY=($( eval command ls "$infopath" 2>/dev/null )); COMPREPLY=(${COMPREPLY[@]##*/?(:)}); for ((i=0 ; i < ${#COMPREPLY[@]} ; ++i )) do if [ "${COMPREPLY[$i]}" == 'dir' ]; then unset COMPREPLY[$i]; fi; done; COMPREPLY=(${COMPREPLY[@]%.@(gz|bz2|xz|lzma)}); COMPREPLY=($( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" )); return 0 } _insmod () { local cur prev modpath; COMPREPLY=(); _get_comp_words_by_ref cur prev; if [[ ${1##*/} == modprobe && "${COMP_WORDS[1]}" == -r ]]; then _installed_modules "$cur"; return 0; fi; if [[ "$cur" == */* ]]; then _filedir '@(?(k)o?(.gz))'; return 0; fi; if [[ $COMP_CWORD -gt 1 && "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then COMPREPLY=($( compgen -W "$( /sbin/modinfo -p ${COMP_WORDS[1]} | cut -d: -f1 )" -- "$cur" )); else _modules $(uname -r); fi; return 0 } _installed_alternatives () { local admindir; for i in alternatives dpkg/alternatives rpm/alternatives; do [ -d /var/lib/$i ] && admindir=/var/lib/$i && break; done; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == --admindir ]]; then admindir=${COMP_WORDS[i+1]}; break; fi; done; COMPREPLY=($( compgen -W '$( command ls $admindir )' -- "$cur" )) } _installed_modules () { COMPREPLY=($( compgen -W "$( PATH="$PATH:/sbin" lsmod | awk '{if (NR != 1) print $1}' )" -- "$1" )) } _ip () { COMPREPLY=(); local cur prev words cword; _get_comp_words_by_ref cur prev words cword; case $prev in -V | -Version | -rc | -rcvbuf) return 0 ;; -f | -family) COMPREPLY=($( compgen -W 'inet inet6 ipx dnet link' -- "$cur" )); return 0 ;; -b | -batch) _filedir; return 0 ;; -force) COMPREPLY=($( compgen -W '-batch' -- "$cur" )); return 0 ;; esac; local subcword cmd subcmd; for ((subcword=1; subcword < ${#words[@]}-1; subcword++ )) do [[ ${words[subcword]} == -b?(atch) ]] && return 0; [[ -n $cmd ]] && subcmd=${words[subcword]} && break; [[ ${words[subcword]} != -* && ${words[subcword-1]} != -@(f?(amily)|rc?(vbuf)) ]] && cmd=${words[subcword]}; done; if [[ -z $cmd ]]; then case $cur in -*) local c="-Version -statistics -details -resolve -family -oneline -timestamp -batch -rcvbuf"; [[ $cword -eq 1 ]] && c="$c -force"; COMPREPLY=($( compgen -W "$c" -- "$cur" )); return 0 ;; *) COMPREPLY=($( compgen -W "help $( ip help 2>&1 | sed -e '/OBJECT := /,/}/!d' -e 's/.*{//' -e 's/}.*//' -e 's/|//g' )" -- "$cur" )); return 0 ;; esac; fi; [[ $subcmd == help ]] && return 0; case $cmd in link) case $subcmd in add) ;; delete) case $(($cword-$subcword)) in 1) _available_interfaces ;; 2) COMPREPLY=($( compgen -W 'type' -- "$cur" )) ;; 3) [[ $prev == type ]] && COMPREPLY=($( compgen -W 'vlan veth vcan dummy ifb macvlan can' -- "$cur" )) ;; esac ;; set) if [[ $cword-$subcword -eq 1 ]]; then _available_interfaces; else case $prev in arp | dynamic | multicast | allmulticast | promisc | trailers) COMPREPLY=($( compgen -W 'on off' -- "$cur" )) ;; txqueuelen | name | address | broadcast | mtu | netns | alias) ;; *) local c="arp dynamic multicast allmulticast promisc trailers txqueuelen name address broadcast mtu netns alias"; [[ $prev != @(up|down) ]] && c="$c up down"; COMPREPLY=($( compgen -W "$c" -- "$cur" )) ;; esac; fi ;; show) [[ $cword -eq $subcword+1 ]] && _available_interfaces ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help add delete set show' -- "$cur" )) ;; esac ;; addr) case $subcmd in add | change | replace) ;; del) ;; show | flush) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help add change replace del show flush' -- "$cur" )) ;; esac ;; addrlabel) case $subcmd in list | add | del | flush) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help list add del flush' -- "$cur" )) ;; esac ;; route) case $subcmd in list | flush) ;; get) ;; add | del | change | append | replace | monitor) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help list flush get add del change append replace monitor' -- "$cur" )) ;; esac ;; rule) case $subcmd in list | add | del | flush) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help list add del flush' -- "$cur" )) ;; esac ;; neigh) case $subcmd in add | del | change | replace) ;; show | flush) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help add del change replace show flush' -- "$cur" )) ;; esac ;; ntable) case $subcmd in change) ;; show) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help change show' -- "$cur" )) ;; esac ;; tunnel) case $subcmd in add | change | del | show | prl | 6rd) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help add change del show prl 6rd' -- "$cur" )) ;; esac ;; maddr) case $subcmd in add | del) ;; show) if [[ $cword -eq $subcword+1 || $prev == dev ]]; then _available_interfaces; [[ $prev != dev ]] && COMPREPLY=($( compgen -W '${COMPREPLY[@]} dev' -- "$cur" )); fi ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help add del show' -- "$cur" )) ;; esac ;; mroute) case $subcmd in show) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help show' -- "$cur" )) ;; esac ;; monitor) case $subcmd in all) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'help all' -- "$cur" )) ;; esac ;; xfrm) case $subcmd in state | policy | monitor) ;; *) [[ $cword -eq $subcword ]] && COMPREPLY=($( compgen -W 'state policy monitor' -- "$cur" )) ;; esac ;; esac } _iptables () { local cur prev table chain; COMPREPLY=(); _get_comp_words_by_ref cur prev; chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'; if [[ $COMP_LINE == *-t\ *filter* ]]; then table="-t filter"; else if [[ $COMP_LINE == *-t\ *nat* ]]; then table="-t nat"; else if [[ $COMP_LINE == *-t\ *mangle* ]]; then table="-t mangle"; fi; fi; fi; _split_longopt; case $prev in -*[AIDRPFXLZ]) COMPREPLY=($( compgen -W '`iptables $table -nL | \ sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" )) ;; -*t) COMPREPLY=($( compgen -W 'nat filter mangle' -- "$cur" )) ;; -j) if [[ "$table" == "-t filter" || -z "$table" ]]; then COMPREPLY=($( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ `iptables $table -nL | sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- "$cur" )); else if [ "$table" = "-t nat" ]; then COMPREPLY=($( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \ sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' -- "$cur" )); else if [ "$table" = "-t mangle" ]; then COMPREPLY=($( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ MARK TOS `iptables $table -nL | sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- "$cur" )); fi; fi; fi ;; *) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--in-interface --out-interface --source \ --destination --protocol --fragment --match --append \ --delete --insert --replace --list --flush --zero --new \ --delete-chain --policy --rename-chain --proto --source \ --destination --in-interface --jump --match --numeric \ --out-interface --table --verbose --line-numbers --exact \ --fragment --modprobe --set-counters --version' -- "$cur")); fi ;; esac } _iwconfig () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in mode) COMPREPLY=($( compgen -W 'managed ad-hoc master \ repeater secondary monitor' -- "$cur" )); return 0 ;; essid) COMPREPLY=($( compgen -W 'on off any' -- "$cur" )); if [ -n "${COMP_IWLIST_SCAN:-}" ]; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( iwlist ${COMP_WORDS[1]} scan | awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" )); fi; return 0 ;; nwid) COMPREPLY=($( compgen -W 'on off' -- "$cur" )); return 0 ;; channel) COMPREPLY=($( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | awk '/^[ \t]*Channel/ {print $2}' )" -- "$cur" )); return 0 ;; freq) COMPREPLY=($( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur" )); return 0 ;; ap) COMPREPLY=($( compgen -W 'on off any' -- "$cur" )); if [ -n "${COMP_IWLIST_SCAN:-}" ]; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( iwlist ${COMP_WORDS[1]} scan | awk -F ': ' '/Address/ {print $2}' )" -- "$cur" )); fi; return 0 ;; rate) COMPREPLY=($( compgen -W 'auto fixed' -- "$cur" )); COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( iwlist ${COMP_WORDS[1]} rate | awk '/^[ \t]*[0-9]/ {print $1"M"}' )" -- "$cur" )); return 0 ;; rts | frag) COMPREPLY=($( compgen -W 'auto fixed off' -- "$cur" )); return 0 ;; key | enc) COMPREPLY=($( compgen -W 'off on open restricted' -- "$cur" )); return 0 ;; power) COMPREPLY=($( compgen -W 'period timeout off on' -- "$cur" )); return 0 ;; txpower) COMPREPLY=($( compgen -W 'off on auto' -- "$cur" )); return 0 ;; retry) COMPREPLY=($( compgen -W 'limit lifetime' -- "$cur" )); return 0 ;; esac; if [ $COMP_CWORD -eq 1 ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --version' -- "$cur" )); else _available_interfaces -w; fi; else COMPREPLY=($( compgen -W 'essid nwid mode freq channel sens mode \ ap nick rate rts frag enc key power txpower commit' -- "$cur" )); fi } _iwlist () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; if [ $COMP_CWORD -eq 1 ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --version' -- "$cur" )); else _available_interfaces -w; fi; else COMPREPLY=($( compgen -W 'scan scanning freq frequency \ channel rate bit bitrate key enc encryption power \ txpower retry ap accesspoint peers event' -- "$cur" )); fi } _iwpriv () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in roam) COMPREPLY=($( compgen -W 'on off' -- "$cur" )); return 0 ;; port) COMPREPLY=($( compgen -W 'ad-hoc managed' -- "$cur" )); return 0 ;; esac; if [ $COMP_CWORD -eq 1 ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --version' -- "$cur" )); else _available_interfaces -w; fi; else COMPREPLY=($( compgen -W '--all roam port' -- "$cur" )); fi } _iwspy () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [ $COMP_CWORD -eq 1 ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --version' -- "$cur" )); else _available_interfaces -w; fi; else COMPREPLY=($( compgen -W 'setthr getthr off' -- "$cur" )); fi } _jarsigner () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -keystore) COMPREPLY=($( compgen -W 'NONE' -- "$cur" )); _filedir '@(jks|ks|p12|pfx)'; return 0 ;; -storepass | -keypass | -sigfile | -digestalg | -sigalg | -tsacert | -altsigner | -altsignerpath | -providerName | -providerClass | -providerArg) return 0 ;; -storetype) COMPREPLY=($( compgen -W 'JKS PKCS11 PKCS12' -- "$cur" )); return 0 ;; -signedjar) _filedir jar; return 0 ;; -tsa) _filedir; return 0 ;; esac; local i jar=false; for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ )) do if [[ "${COMP_WORDS[i]}" == *.jar && "${COMP_WORDS[i-1]}" != -signedjar ]]; then jar=true; break; fi; done; if ! $jar; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-keystore -storepass -storetype \ -keypass -sigfile -signedjar -digestalg -sigalg -verify \ -verbose -certs -tsa -tsacert -altsigner -altsignerpath \ -protected -providerName -providerClass -providerArg' -- "$cur" )); fi; _filedir jar; fi } _java () { local cur prev words cword i; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev words cword; for ((i=1; i < $cword; i++)) do case ${words[$i]} in -cp | -classpath) ((i++)) ;; -*) ;; *) _filedir; return 0 ;; esac; done; case $cur in -verbose:*) COMPREPLY=($( compgen -W 'class gc jni' -- "${cur#*:}" )); return 0 ;; -javaagent:*) cur=${cur#*:}; _filedir '@(jar|zip)'; return 0 ;; -agentpath:*) cur=${cur#*:}; _filedir so; return 0 ;; -splash:*) cur=${cur#*:}; _filedir '@(gif|jp?(e)g|png)'; return 0 ;; -Xbootclasspath*:*) _java_path; return 0 ;; -Xcheck:*) COMPREPLY=($( compgen -W 'jni' -- "${cur#*:}" )); return 0 ;; -Xgc:*) COMPREPLY=($( compgen -W 'singlecon gencon singlepar genpar' -- "${cur#*:}" )); return 0 ;; -Xgcprio:*) COMPREPLY=($( compgen -W 'throughput pausetime deterministic' -- "${cur#*:}" )); return 0 ;; -Xloggc:* | -Xverboselog:*) cur=${cur#*:}; _filedir; return 0 ;; -Xshare:*) COMPREPLY=($( compgen -W 'auto off on' -- "${cur#*:}" )); return 0 ;; -Xverbose:*) COMPREPLY=($( compgen -W 'memory load jni cpuinfo codegen opt gcpause gcreport' -- "${cur#*:}" )); return 0 ;; -Xverify:*) COMPREPLY=($( compgen -W 'all none remote' -- "${cur#*:}" )); return 0 ;; -D* | -*:*) return 0 ;; esac; case $prev in -cp | -classpath) _java_path; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-client -server -agentlib: -agentpath: -classpath -D -d32 -d64 -enableassertions -disableassertions -enablesystemassertions -disablesystemassertions -jar -javaagent: -verbose -verbose -version -showversion -help -X' -- "$cur" )); else if [[ "$prev" == -jar ]]; then _filedir jar; else _java_classes; fi; fi; [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == -*[:=] ]] && type compopt &>/dev/null && compopt -o nospace; __ltrim_colon_completions "$cur" } _java_classes () { local classpath i; _java_find_classpath; cur=${cur//.//}; for i in ${classpath//:/ }; do if [[ "$i" == *.@(jar|zip) && -r $i ]]; then if type zipinfo &>/dev/null; then COMPREPLY=("${COMPREPLY[@]}" $( zipinfo -1 "$i" "$cur*" 2>/dev/null | command grep '^[^$]*\.class$' )); else COMPREPLY=("${COMPREPLY[@]}" $( jar tf "$i" "$cur" | command grep '^[^$]*\.class$' )); fi; else if [ -d $i ]; then COMPREPLY=("${COMPREPLY[@]}" $( command ls $i/$cur*.class 2>/dev/null | sed -ne '/\$/d' -e "s|^$i//*||p" )); fi; fi; done; COMPREPLY=(${COMPREPLY[@]%.class}); COMPREPLY=(${COMPREPLY[@]//\//.}) } _java_find_classpath () { local i; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == -@(cp|classpath) ]]; then classpath=${COMP_WORDS[i+1]}; break; fi; done; [ -z "$classpath" ] && classpath=$CLASSPATH; [ -z "$classpath" ] && classpath=. } _java_find_sourcepath () { local i; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then sourcepath=${COMP_WORDS[i+1]}; break; fi; done; if [ -z "$sourcepath" ]; then _java_find_classpath; sourcepath=$classpath; fi } _java_packages () { local sourcepath i; _java_find_sourcepath; cur=${cur//.//}; for i in ${sourcepath//:/ }; do if [ -d $i ]; then COMPREPLY=("${COMPREPLY[@]}" $( command ls -F -d $i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' )); fi; done; COMPREPLY=($( tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$" )); COMPREPLY=(${COMPREPLY[@]%/}); cur=${COMPREPLY[@]//\//.} } _java_path () { cur=${cur##*:}; _filedir '@(jar|zip)' } _javac () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -d) _filedir -d; return 0 ;; -classpath | -bootclasspath | -sourcepath | -extdirs) _java_path; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-g -g:none -g:lines -g:vars \ -g:source -O -nowarn -verbose -deprecation -classpath \ -sourcepath -bootclasspath -extdirs -d -encoding -source \ -target -help' -- "$cur" )); else _filedir java; fi } _javadoc () { COMPREPLY=(); local cur prev classpath; _get_comp_words_by_ref cur prev; case $prev in -overview | -helpfile) _filedir '?(x)htm?(l)'; return 0 ;; -stylesheetfile) _filedir css; return 0 ;; -d | -link | -linkoffline) _filedir -d; return 0 ;; -classpath | -bootclasspath | -docletpath | -sourcepath | -extdirs) _java_path; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-overview -public -protected \ -package -private -help -doclet -docletpath \ -sourcepath -classpath -exclude -subpackages \ -breakiterator -bootclasspath -source -extdirs \ -verbose -locale -encoding -J -d -use -version \ -author -docfilessubdirs -splitindex \ -windowtitle -doctitle -header -footer -bottom \ -link -linkoffline -excludedocfilessubdir \ -group -nocomment -nodeprecated -noqualifier \ -nosince -nodeprecatedlist -notree -noindex \ -nohelp -nonavbar -quiet -serialwarn -tag \ -taglet -tagletpath -charset -helpfile \ -linksource -stylesheetfile -docencoding' -- "$cur" )); else _filedir java; _java_packages; fi } _javaws () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -help | -license | -about | -viewer | -arg | -param | -property | -update | -umask) return 0 ;; -basedir | -codebase) _filedir -d; return 0 ;; -uninstall | -import) _filedir jnlp; return 0 ;; esac; if [[ $cur == -* ]]; then COMPREPLY=($( compgen -W "$( _parse_help "$1" -help ) " -- "$cur" )); return 0; fi; _filedir jnlp } _kernel_versions () { COMPREPLY=($( compgen -W '$( command ls /lib/modules )' -- "$cur" )) } _kill () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then _signals; else _pids; fi } _killall () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then _signals; else _pnames; fi; return 0 } _known_hosts () { local options; COMPREPLY=(); [[ "$1" == -a || "$2" == -a ]] && options=-a; [[ "$1" == -c || "$2" == -c ]] && options="$options -c"; _known_hosts_real $options "$(_get_cword :)" } _known_hosts_real () { local configfile flag prefix; local cur curd awkcur user suffix aliases i host; local -a kh khd config; local OPTIND=1; while getopts "acF:p:" flag "$@"; do case $flag in a) aliases='yes' ;; c) suffix=':' ;; F) configfile=$OPTARG ;; p) prefix=$OPTARG ;; esac; done; [ $# -lt $OPTIND ] && echo "error: $FUNCNAME: missing mandatory argument CWORD"; cur=${!OPTIND}; let "OPTIND += 1"; [ $# -ge $OPTIND ] && echo "error: $FUNCNAME("$@"): unprocessed arguments:" $(while [ $# -ge $OPTIND ]; do printf '%s\n' ${!OPTIND}; shift; done); [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}; kh=(); if [ -n "$configfile" ]; then [ -r "$configfile" ] && config=("${config[@]}" "$configfile"); else for i in /etc/ssh/ssh_config "${HOME}/.ssh/config" "${HOME}/.ssh2/config"; do [ -r $i ] && config=("${config[@]}" "$i"); done; fi; if [ ${#config[@]} -gt 0 ]; then local OIFS=$IFS IFS=' '; local -a tmpkh; tmpkh=($( awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u )); for i in "${tmpkh[@]}"; do i=${i//\"}; __expand_tilde_by_ref i; [ -r "$i" ] && kh=("${kh[@]}" "$i"); done; IFS=$OIFS; fi; if [ -z "$configfile" ]; then for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts ~/.ssh/known_hosts2; do [ -r $i ] && kh=("${kh[@]}" $i); done; for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do [ -d $i ] && khd=("${khd[@]}" $i/*pub); done; fi; if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 ]]; then awkcur=${cur//\//\\\/}; awkcur=${awkcur//\./\\\.}; curd=$awkcur; if [[ "$awkcur" == [0-9]*[.:]* ]]; then awkcur="^$awkcur[.:]*"; else if [[ "$awkcur" == [0-9]* ]]; then awkcur="^$awkcur.*[.:]"; else if [ -z "$awkcur" ]; then awkcur="[a-z.:]"; else awkcur="^$awkcur"; fi; fi; fi; if [ ${#kh[@]} -gt 0 ]; then COMPREPLY=("${COMPREPLY[@]}" $( awk 'BEGIN {FS=","} /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \ sub(" .*$", "", $i); \ sub("^\\[", "", $i); sub("\\](:[0-9]+)?$", "", $i); \ if ($i ~ /'"$awkcur"'/) {print $i} \ }}' "${kh[@]}" 2>/dev/null )); fi; if [ ${#khd[@]} -gt 0 ]; then for i in "${khd[@]}"; do if [[ "$i" == *key_22_$curd*.pub && -r "$i" ]]; then host=${i/#*key_22_/}; host=${host/%.pub/}; COMPREPLY=("${COMPREPLY[@]}" $host); fi; done; fi; for ((i=0; i < ${#COMPREPLY[@]}; i++ )) do COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix; done; fi; 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[@]}" ); COMPREPLY=("${COMPREPLY[@]}" $( compgen -P "$prefix$user" -S "$suffix" -W "$hosts" -- "$cur" )); fi; if [[ -n ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && type avahi-browse &>/dev/null; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -P "$prefix$user" -S "$suffix" -W "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | awk -F';' '/^=/ { print $7 }' | sort -u )" -- "$cur" )); fi; if [ -n "${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}" ]; then COMPREPLY=("${COMPREPLY[@]}" $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" )); fi; __ltrim_colon_completions "$prefix$user$cur"; return 0 } _l2ping () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -i) _bluetooth_devices; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-i -s -c -t -f -r' -- "$cur" )); else _bluetooth_adresses; fi } _lastlog () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -b | --before | -h | --help | -t | --time) return 0 ;; -u | --user) COMPREPLY=($( compgen -u -- "$cur" )); return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--before --help --time --user' -- "$cur" )); return 0; fi } _lftp () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -f) _filedir; return 0 ;; -c | -h | --help | -v | --version | -e | -u | -p) return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-f -c --help --version -e -u -p' -- "$cur" )); return 0; fi; COMPREPLY=($( compgen -W '$( cut -f 1 -s ~/.lftp/bookmarks 2>/dev/null )' -- "$cur" )); _known_hosts_real "$cur" } _lftpget () { COMPREPLY=(); local cur; _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-c -d -v' -- "$cur" )); fi } _linux_fstab () { COMPREPLY=(); local fs_spec fs_file fs_other; local oldifs="$IFS"; while read -r fs_spec fs_file fs_other; do if [[ $fs_spec = [#]* ]]; then continue; fi; if [[ $1 == -L ]]; then local fs_label=${fs_spec/#LABEL=}; if [[ $fs_label != "$fs_spec" ]]; then __linux_fstab_unescape fs_label; IFS=''; COMPREPLY+=("$fs_label"); IFS=$oldifs; fi; else __linux_fstab_unescape fs_spec; __linux_fstab_unescape fs_file; IFS=''; [[ $fs_spec = */* ]] && COMPREPLY+=("$fs_spec"); [[ $fs_file = */* ]] && COMPREPLY+=("$fs_file"); IFS=$oldifs; fi; done; _reply_compgen_array } _longopt () { local cur prev split=false; _get_comp_words_by_ref -n = cur prev; _split_longopt && split=true; case "$prev" in --*[Dd][Ii][Rr]*) _filedir -d; return 0 ;; --*[Ff][Ii][Ll][Ee]* | --*[Pp][Aa][Tt][Hh]*) _filedir; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$( $1 --help 2>&1 | sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}\).*/\1/p' | sort -u )" -- "$cur" )); else if [[ "$1" == @(mk|rm)dir ]]; then _filedir -d; else _filedir; fi; fi } _look () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [ $COMP_CWORD = 1 ]; then COMPREPLY=($( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" )); fi } _lsof () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -'?' | -h | +c | -c | -d | -F | -i | +r | -r | -s | -S | -T) return 0 ;; -A | -k | -m | +m | -o) _filedir; return 0 ;; +d | +D) _filedir -d; return 0 ;; -D) COMPREPLY=($( compgen -W '? b i r u' -- "$cur" )); return 0 ;; -f) COMPREPLY=($( compgen -W 'c f g G n' -- "$cur" )); return 0 ;; -g) _pgids; return 0 ;; -p) _pids; return 0 ;; -u) COMPREPLY=($( compgen -u -- "$cur" )); return 0 ;; esac; if [[ "$cur" == [-+]* ]]; then COMPREPLY=($( compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g -i -k -l +L -L +m -m +M -M -n -N -o -O -p -P +r -r -R -s -S -T -t -u -U -v -V +w -w -x -X -z -Z' -- "$cur" )); return 0; fi; _filedir } _mac_addresses () { local re='\([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}'; local PATH="$PATH:/sbin:/usr/sbin"; COMPREPLY=("${COMPREPLY[@]}" $( ifconfig -a 2>/dev/null | sed -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" )); COMPREPLY=("${COMPREPLY[@]}" $( arp -an 2>/dev/null | sed -ne "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" )); COMPREPLY=("${COMPREPLY[@]}" $( sed -ne "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null )); COMPREPLY=($( compgen -W '${COMPREPLY[@]}' -- "$cur" )); __ltrim_colon_completions "$cur" } _make () { local file makef makef_dir="." makef_inc cur prev i split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -f | -o | -W | --file | --makefile | --old-file | --new-file | --assume-old | --assume-new | --what-if) _filedir; return 0 ;; -I | -C | --directory | --include-dir) _filedir -d; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-b -m -B -C -d -e -f -h -i -I\ -j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \ --always-make --directory --debug \ --environment-overrides --file --makefile --help \ --ignore-errors --include-dir --jobs --load-average \ --max-load --keep-going --just-print --dry-run \ --recon --old-file --assume-old --print-data-base \ --question --no-builtin-rules --no-builtin-variables \ --silent --quiet --no-keep-goind --stop --touch \ --version --print-directory --no-print-directory \ --what-if --new-file --assume-new \ --warn-undefined-variables' -- "$cur" )); else for ((i=0; i < ${#COMP_WORDS[@]}; i++ )) do if [[ ${COMP_WORDS[i]} == -@(C|-directory) ]]; then eval makef_dir=${COMP_WORDS[i+1]}; break; fi; done; for ((i=0; i < ${#COMP_WORDS[@]}; i++ )) do if [[ ${COMP_WORDS[i]} == -@(f|-?(make)file) ]]; then eval makef=${COMP_WORDS[i+1]}; break; fi; done; [ -n "$makef" ] && makef="-f ${makef}"; [ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}"; COMPREPLY=($( compgen -W "$( make -qp $makef $makef_dir 2>/dev/null | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \ {split($1,A,/ /);for(i in A)print A[i]}' )" -- "$cur" )); fi } _man () { local cur i prev sect manpath manext mansect uname; manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@([gx]z|bz2|lzma|Z))"; mansect="@([0-9lnp]|[0-9][px]|3pm)"; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev; if [[ "$prev" == -l ]]; then _filedir $manext; return 0; fi; _expand || return 0; if [[ "$cur" == */* ]]; then _filedir $manext; return 0; fi; uname=$( uname -s ); if [[ $uname == @(Linux|GNU|GNU/*|FreeBSD|Cygwin|CYGWIN_*) ]]; then manpath=$( manpath 2>/dev/null || command man --path ); else manpath=$MANPATH; fi; if [ -z "$manpath" ]; then COMPREPLY=($( compgen -c -- "$cur" )); return 0; fi; [[ "$prev" == $mansect ]] && sect=$prev || sect='*'; manpath=$manpath:; if [ -n "$cur" ]; then manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"; else manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"; fi; COMPREPLY=($( eval command ls "$manpath" 2>/dev/null )); COMPREPLY=(${COMPREPLY[@]##*/?(:)}); COMPREPLY=(${COMPREPLY[@]%.@([gx]z|bz2|lzma|Z)}); COMPREPLY=($( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" )); if [[ "$prev" != $mansect ]]; then local start=${#COMPREPLY[@]}; _filedir $manext; for ((i=$start; i < ${#COMPREPLY[@]}; i++ )) do [[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}; done; fi; __ltrim_colon_completions "$cur"; return 0 } _mdadm () { local cur prev mode options split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -c | --config | -b | --bitmap | --backup-file) _filedir; return 0 ;; -l | --level) _mdadm_raid_level; return 0 ;; -p | --layout | --parity) _mdadm_raid_layout; return 0 ;; -a | --auto) _mdadm_auto_flag; return 0 ;; -U | --update) _mdadm_update_flag; return 0 ;; esac; $split && return 0; options='--help --help-options --version --verbose --quiet \ --brief --force --config --scan --metadata --homehost'; if [[ "$cur" == -* ]]; then if [[ $COMP_CWORD -eq 1 ]]; then COMPREPLY=($( compgen -W "$options --assemble --build --create --monitor --grow" -- "$cur" )); else case ${COMP_WORDS[COMP_CWORD-1]} in -A | --assemble) 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) 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) COMPREPLY=($( compgen -W "$options --mail --program --alert --syslog --delay --daemonise --pid-file --oneshot --test" -- "$cur" )) ;; /dev/* | --add | --fail | --remove) COMPREPLY=($( compgen -W "$options --add --re-add --remove --fail --set-faulty" -- "$cur" )) ;; *) COMPREPLY=($( compgen -W "$options --query --detail --examine --sparc2.2 --examine-bitmap --run --stop --readonly --readwrite --zero-superblock --test" -- "$cur" )) ;; esac; fi; else cur=${cur:=/dev/}; _filedir; fi } _mdadm_auto_flag () { COMPREPLY=($( compgen -W 'no yes md mdp part p' -- "$cur" )) } _mdadm_raid_layout () { local level; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == -@(l|-level) ]]; then level=${COMP_WORDS[i+1]}; break; fi; done; case $level in raid5) COMPREPLY=($( compgen -W 'left-asymmetric left-symmetric \ right-asymmetric right-symmetric la ra ls rs' -- "$cur" )) ;; raid10) COMPREPLY=($( compgen -W 'n o p' -- "$cur" )) ;; faulty) COMPREPLY=($( compgen -W 'write-transient wt read-transient rt \ write-persistent wp read-persistent rp write-all read-fixable \ rf clear flush none' -- $cur )) ;; esac } _mdadm_raid_level () { local mode; for ((i=1; i < COMP_CWORD; i++ )) do case ${COMP_WORDS[i]} in -C | --create) mode=create; break ;; -B | --build) mode=build; break ;; esac; done; case $mode in create) COMPREPLY=($( compgen -W 'linear raid0 0 stripe raid1 1 mirror \ raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' -- "$cur" )) ;; build) COMPREPLY=($( compgen -W 'linear stripe raid0 0 raid1 multipath \ mp faulty' -- "$cur" )) ;; esac } _mdadm_update_flag () { COMPREPLY=($( compgen -W 'sparc2.2 summaries uuid name homehost resync \ byteorder super-minor' -- "$cur" )) } _mii_diag () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | -A | --advertise | --fixed-speed) COMPREPLY=($( compgen -W '100baseT4 100baseTx \ 100baseTx-FD 100baseTx-HD 10baseT 10baseT-FD \ 10baseT-HD' -- "$cur" )); return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--advertise --fixed-speed --all-interfaces \ --status --debug --read-parameters --set-parameters --msg-level \ --phy --restart --reset --verbose --version --watch --help' -- "$cur" )); else _available_interfaces -a; fi } _mii_tool () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --force) COMPREPLY=($( compgen -W '100baseTx-FD 100baseTx-HD \ 10baseT-FD 10baseT-HD' -- "$cur" )); return 0 ;; -A | --advertise) COMPREPLY=($( compgen -W '100baseT4 100baseTx-FD 100baseTx-HD \ 10baseT-FD 10baseT-HD' -- "$cur" )); return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--verbose --version --reset --restart \ --watch --log --advertise --force' -- "$cur" )); else _available_interfaces -a; fi } _mkisofs () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -o | -abstract | -biblio | -check-session | -copyright | -log-file | -root-info | -prep-boot | -*-list) _filedir; return 0 ;; -*-charset) COMPREPLY=($( compgen -W '$( mkisofs -input-charset \ help 2>&1 | tail -n +3 )' -- "$cur" )); return 0 ;; -uid) _uids; return 0 ;; -gid) _gids; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-abstract -appid -allow-lowercase \ -allow-multidot -biblio -cache-inodes -no-cache-inodes \ -eltorito-boot -eltorito-alt-boot -sparc-boot -generic-boot \ -hard-disk-boot -no-emul-boot -no-boot -boot-load-seg \ -boot-load-size -boot-info-table -cdrecord-params \ -eltorito-catalog -check-oldname -check-session -copyright \ -omit-period -disable-deep-relocation -dir-mode -dvd-video \ -follow-links -file-mode -gid -gui -graft-points -hide -hide-list \ -hidden -hidden-list -hide-joliet -hide-joliet-list \ -hide-joliet-trans-tbl -hide-rr-moved -input-charset \ -output-charset -iso-level -joliet -joliet-long -jcharset \ -full-iso9660-filenames -allow-leading-dots -log-file -exclude \ -exclude-list -max-iso9660-filenames -prev-session \ -omit-version-number -new-dir-mode -nobak -no-bak -force-rr -no-rr \ -no-split-symlink-components -no-split-symlink-fields -output -pad \ -no-pad -path-list -publisher -preparer -print-size -quiet -rock -rational-rock -relaxed-filenames -sort -split-output \ -stream-media-size -stream-file-name -sysid -translation-table \ -table-name -ucs-level -udf -uid -use-fileversion \ -untranslated-filenames -no-iso-translate -volid -volset \ -volset-size -volset-seqno -verbose -old-exclude \ -transparent-compression -hfs -apple -map -magic -hfs-creator \ -hfs-type -probe -no-desktop -mac-name \ -boot-hfs-file -part -auto -cluster-size \ -hide-hfs -hide-hfs-list -hfs-volid \ -icon-position -root-info -prep-boot \ -input-hfs-charset -output-hfs-charset \ -hfs-unlock -hfs-bless -hfs-parms --cap \ --netatalk --double --ethershare --ushare \ --exchange --sgi --xinet --macbin --single \ --dave --sfm --osx-double --osx-hfs' -- "$cur" )); else _filedir; fi } _mktemp () { COMPREPLY=(); local cur prev split=false; _get_comp_words_by_ref cur prev; _split_longopt && split=true; case "$prev" in --help | --version | --suffix) return 0 ;; --tmpdir | -p) _filedir -d; return 0 ;; esac; $split && return 0; [[ "$cur" == -* ]] && COMPREPLY=($( compgen -W '-d -u -q -p -t' -- "$cur" )) } _modules () { local modpath; modpath=/lib/modules/$1; COMPREPLY=($( compgen -W "$( command ls -R $modpath | sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.gz\)\{0,1\}$/\1/p' )" -- "$cur" )) } _mount () { local cur sm host prev; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev; case $prev in -t | --types) _fstypes; return 0 ;; esac; [[ "$cur" == \\ ]] && cur="/"; if [[ "$cur" == *:* ]]; then for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do [ -x "$sm" ] || continue; COMPREPLY=($( compgen -W "$( "$sm" -e ${cur%%:*} | awk 'NR>1 {print $1}' )" -- "${cur#*:}" )); return 0; done; fi; if [[ "$cur" == //* ]]; then host=${cur#//}; host=${host%%/*}; if [ -n "$host" ]; then COMPREPLY=($( compgen -P "//$host" -W "$( smbclient -d 0 -NL $host 2>/dev/null | sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' | sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" -- "${cur#//$host}" )); fi; else if [ -r /etc/vfstab ]; then COMPREPLY=($( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" )); else if [ ! -e /etc/fstab ]; then COMPREPLY=($( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" )); else if [ "$prev" = -L ]; then _linux_fstab -L < /etc/fstab; else if [ "$prev" = -U ]; then COMPREPLY=($( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- "$cur" )); else _linux_fstab < /etc/fstab; fi; fi; fi; fi; fi; return 0 } _mplayer () { local cmd cur prev i j k=0; COMPREPLY=(); cmd=${COMP_WORDS[0]}; _get_comp_words_by_ref cur prev; case $prev in -[av][cfo] | -[av]fm | -vop | -fstype | -demuxer | -o[av]c | -of | -profile | -audio-demuxer | -sub-demuxer) _mplayer_options_list $cmd $prev; return 0 ;; -show-profile) _mplayer_options_list $cmd -profile; return 0 ;; -audiofile) _filedir '@(mp3|mpg|ogg|w?(a)v|mid|flac|mka|ape)'; return 0 ;; -font | -subfont) if [ "$prev" = -font ]; then _filedir '@(desc|ttf)'; else _filedir ttf; fi; local IFS=' '; COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '$( fc-list 2>/dev/null )' -- "$cur" )); return 0 ;; -sub) _filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'; return 0 ;; -vobsub) _filedir '@(idx|ifo|sub)'; local IFS=' '; COMPREPLY=($( for i in "${COMPREPLY[@]}"; do if [[ -f $i && -r $i ]]; then printf '%s\n' ${i%.*} else printf '%s\n' $i fi done )); return 0 ;; -ifo) _filedir ifo; return 0 ;; -cuefile) _filedir '@(bin|cue)'; return 0 ;; -skin) local -a dirs; if [ -n "$MPLAYER_SKINS_DIR" ]; then dirs=($MPLAYER_SKINS_DIR); else dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins); fi; local IFS=' '; for i in ~/.mplayer/skins ${dirs[@]}; do if [[ -d $i && -r $i ]]; then for j in $( compgen -d $i/$cur ); do COMPREPLY[$k]=${j#$i/}; k=$((++k)); done; fi; done; return 0 ;; -cdrom-device) _cd_devices; _dvd_devices; return 0 ;; -dvd-device) _filedir; return 0 ;; -mixer | -dvdauth | -fb | -zrdev) cur=${cur:=/dev/}; _filedir; return 0 ;; -edl | -edlout | -lircconf | -menu-cfg | -playlist | -csslib | -dumpfile | -subfile | -vobsub | -aofile | -fbmodeconfig | -include | -o | -dvdkey | -passlogfile) _filedir; return 0 ;; -autoq | -autosync | -loop | -menu-root | -speed | -sstep | -aid | -alang | -bandwidth | -cache | -chapter | -dvd | -dvdangle | -fps | -frames | -mc | -passwd | -user | -sb | -srate | -ss | -vcd | -vi | -vid | -vivo | -ffactor | -sid | -slang | -spualign | -spuaa | -spugauss | -vobsubid | -delay | -bpp | -brightness | -contrast | -dfbopts | -display | -fbmode | -geometry | -guiwid | -hue | -icelayer | -screen[wh] | -wid | -monitoraspect | -monitor-dotclock | -monitor-[hv]freq | -panscan | -saturation | -xineramascreen | -zrcrop | -zrnorm | -zrquality | -zr[xy]doff | -zr[vh]dec | -aspect | -pp | -x | -y | -xy | -z | -stereo | -audio-density | -audio-delay | -audio-preload | -endpos | -osdlevel | -ffourcc | -sws | -channels | -skiplimit | -format | -ofps | -aadriver | -aaosdcolor | -aasubcolor | -vobsubout | -vobsuboutid | -vobsuboutindex | -sub-bg-alpha | -sub-bg-color | -sub-cp | -sub-delay | -sub-fps | -sub-pos | -sub-align | -sub-width | -subfont-blur | -subfont-outline | -subfont-autoscale | -subfont-encoding | -subfont-osd-scale | -subfont-osd-text) return 0 ;; -lavdopts) COMPREPLY=($( compgen -W 'bitexact bug= debug= ec= er= fast gray idct= lowres= sb= st= skiploopfilter= skipidct= skipframe= threads= vismv= vstats' -- "$cur" )); return 0 ;; -lavcopts) COMPREPLY=($( compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= \ mbqmax= vqdiff= vmax_b_frames= vme= vhq v4mv keyint= \ vb_strategy= vpass= aspect= vbitrate= vratetol= vrc_maxrate= \ vrc_minrate= vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset= \ vi_qoffset= vqblur= vqcomp= vrc_eq= vrc_override= \ vrc_init_cplx= vqsquish= vlelim= vcelim= vstrict= vdpart \ vpsize= gray vfdct= idct= lumi_mask= dark_mask= tcplx_mask= \ scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp= \ predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic \ umv' -- "$cur" )); return 0 ;; -ssf) COMPREPLY=($( compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur" )); return 0 ;; -jpeg) COMPREPLY=($( compgen -W 'noprogressive progressive nobaseline \ baseline optimize= smooth= quality= outdir=' -- "$cur" )); return 0 ;; -xvidopts) COMPREPLY=($( compgen -W 'dr2 nodr2' -- "$cur" )); return 0 ;; -xvidencopts) COMPREPLY=($( compgen -W 'pass= bitrate= fixed_quant= me_quality= \ 4mv rc_reaction_delay_factor= rc_averaging_period= rc_buffer= \ quant_range= min_key_interval= max_key_interval= mpeg_quant \ mod_quant lumi_mask hintedme hintfile debug keyframe_boost= \ kfthreshold= kfreduction=' -- "$cur" )); return 0 ;; -divx4opts) COMPREPLY=($( compgen -W 'br= key= deinterlace q= min_quant= \ max_quant= rc_period= rc_reaction_period= crispness= \ rc_reaction_ratio= pass= vbrpass= help' -- "$cur" )); return 0 ;; -info) COMPREPLY=($( compgen -W 'name= artist= genre= subject= \ copyright= srcform= comment= help' -- "$cur" )); return 0 ;; -lameopts) COMPREPLY=($( compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= \ mode= padding= fast preset= help' -- "$cur" )); return 0 ;; -rawaudio) COMPREPLY=($( compgen -W 'on channels= rate= samplesize= format=' -- "$cur" )); return 0 ;; -rawvideo) COMPREPLY=($( compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= \ h= y420 yv12 yuy2 y8 format= size=' -- "$cur" )); return 0 ;; -aop) COMPREPLY=($( compgen -W 'list= delay= format= fout= volume= mul= \ softclip' -- "$cur" )); return 0 ;; -dxr2) COMPREPLY=($( compgen -W 'ar-mode= iec958-encoded iec958-decoded \ mute ucode= 75ire bw color interlaced macrovision= norm= \ square-pixel ccir601-pixel cr-left= cr-right= cr-top= cr-bot= \ ck-rmin= ck-gmin= ck-bmin= ck-rmax= ck-gmax= ck-bmax= ck-r= \ ck-g= ck-b= ignore-cache= ol-osd= olh-cor= olw-cor= olx-cor= \ oly-cor= overlay overlay-ratio= update-cache' -- "$cur" )); return 0 ;; -tv) COMPREPLY=($( compgen -W 'on noaudio driver= device= input= freq= \ outfmt= width= height= buffersize= norm= channel= chanlist= \ audiorate= forceaudio alsa amode= forcechan= adevice= audioid= \ volume= bass= treble= balance= fps= channels= immediatemode=' -- "$cur" )); return 0 ;; -mf) COMPREPLY=($( compgen -W 'on w= h= fps= type=' -- "$cur" )); return 0 ;; -cdda) COMPREPLY=($( compgen -W 'speed= paranoia= generic-dev= \ sector-size= overlap= toc-bias toc-offset= skip noskip' \ -- "$cur" )); return 0 ;; -input) COMPREPLY=($( compgen -W 'conf= ar-delay ar-rate keylist cmdlist \ js-dev file' -- "$cur" )); return 0 ;; -af) COMPREPLY=($( compgen -W 'resample resample= channels channels= \ format format= volume volume= delay delay= pan pan= sub sub= \ surround surround=' -- "$cur" )); return 0 ;; -af-adv) COMPREPLY=($( compgen -W 'force= list=' -- "$cur" )); return 0 ;; -noconfig) COMPREPLY=($( compgen -W 'all gui system user' -- "$cur" )); return 0 ;; esac; case $cur in -*) COMPREPLY=($( compgen -W '$( $cmd -nomsgcolor -nomsgmodule -list-options 2>/dev/null | \ sed -ne '1,/^[[:space:]]*Name/d' \ -e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \ -e "/^-\(Total\|.*\*\)\{0,1\}$/!p" )' -- "$cur" )) ;; *) _filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m4[av]|M4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m[24]v|M[24]V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|webm|WEBM|amr|AMR|awb|AWB|iso|ISO)?(.part)' ;; esac; return 0 } _mplayer_options_list () { cur=${cur%\\}; COMPREPLY=($( compgen -W "$( $1 -nomsgcolor -nomsgmodule $2 help 2>/dev/null | sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' | sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' )" -- "$cur" )) } _mutt () { local cur prev; _get_comp_words_by_ref -n =+! cur prev; COMPREPLY=(); case $cur in -*) COMPREPLY=($( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \ -p -Q -R -s -v -x -y -z -Z -h' -- "$cur" )); return 0 ;; *) case $prev in -a | -f | -F | -H | -i) _muttfiledir "$cur"; return 0 ;; -A) _muttaliases "$cur"; return 0 ;; -e | -m | -Q | -s | -h | -p | -R | -v | -y | -z | -Z) return 0 ;; *) _muttaddr "$cur"; return 0 ;; esac ;; esac } _muttaddr () { _muttaliases "$1"; _muttquery "$1"; COMPREPLY=("${COMPREPLY[@]}" $( compgen -u -- "$1" )); return 0 } _muttaliases () { local cur=$1 muttrc muttcmd=${COMP_WORDS[0]}; local -a conffiles aliases; muttrc=$(_muttrc); [ -z "$muttrc" ] && return 0; conffiles=($(eval _muttconffiles $muttrc $muttrc)); aliases=($( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo "${conffiles[@]}") )); COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- "$cur" )); return 0 } _muttconffiles () { local file sofar; local -a newconffiles; sofar=" $1 "; shift; while [[ -n "$1" ]]; do newconffiles=($(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) )); for file in "${newconffiles[@]}"; do [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] && continue; sofar="$sofar $file"; sofar=" $(eval _muttconffiles \"$sofar\" $file) "; done; shift; done; printf '%s\n' $sofar } _muttfiledir () { local cur=$1 folder muttrc spoolfile muttcmd=${COMP_WORDS[0]}; muttrc=$(_muttrc); if [[ $cur == [=+]* ]]; then folder="$( $muttcmd -F "$muttrc" -Q folder | sed -e 's|^folder=\"\(.*\)\"$|\1|' )"; : folder:=~/Mail; _compopt_o_filenames; COMPREPLY=($( compgen -f -- "$folder/${cur:1}" )); COMPREPLY=(${COMPREPLY[@]#$folder/}); return 0; else if [ "$cur" == !* ]; then spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile | sed -e 's|^spoolfile=\"\(.*\)\"$|\1|' )"; [ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}"; fi; fi; _filedir; return 0 } _muttquery () { local cur=$1 querycmd muttcmd=${COMP_WORDS[0]}; local -a queryresults; querycmd="$( $muttcmd -Q query_command | sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|' )"; if [[ -z "$cur" || -z "$querycmd" ]]; then queryresults=(); else queryresults=($( $querycmd | sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p' )); fi; COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" -- "$cur" )); return 0 } _muttrc () { set -- "${COMP_WORDS[@]}"; while [ $# -gt 0 ]; do if [ "${1:0:2}" = -F ]; then if [ ${#1} -gt 2 ]; then muttrc="$(dequote "${1:2}")"; else shift; [ "$1" ] && muttrc="$(dequote "$1")"; fi; break; fi; shift; done; if [ -z "$muttrc" ]; then if [ -f ~/.${muttcmd}rc ]; then muttrc="~/.${muttcmd}rc"; else if [ -f ~/.${muttcmd}/${muttcmd}rc ]; then muttrc="~/.${muttcmd}/${muttcmd}rc"; fi; fi; fi; printf "%s" "$muttrc" } _ncftp () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ $COMP_CWORD -eq 1 && -f ~/.ncftp/bookmarks ]]; then COMPREPLY=($( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ ~/.ncftp/bookmarks )' -- "$cur" )); fi; return 0 } _newgrp () { COMPREPLY=(); if [[ "`_get_cword`" == "-" ]]; then COMPREPLY=(-); else _allowed_groups; fi } _newusers () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -c | --crypt) COMPREPLY=($( compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur" )); return 0 ;; -s | --sha-rounds) return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--crypt-method --help --system \ --sha-rounds' -- "$cur" )); return 0; fi; _filedir } _nslookup () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; COMPREPLY=($( compgen -P '-' -W 'all class= debug d2 domain= srchlist= \ defname search port= querytype= type= recurse retry root timeout vc \ ignoretc' -- "$cur" )) } _ntpdate () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -k) _filedir; return 0 ;; -U) COMPREPLY=($( compgen -u "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\ -e -k -p -o -r -t' -- "$cur" )); else _known_hosts_real "$cur"; fi } _openssl () { local cur prev commands command options formats; COMPREPLY=(); _get_comp_words_by_ref cur prev; commands='asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa \ dsaparam ec ecparam enc engine errstr gendh gendsa genrsa \ nseq ocsp passwd pkcs12 pkcs7 pkcs8 prime rand req rsa \ rsautl s_client s_server s_time sess_id smime speed spkac \ verify version x509 md2 md4 md5 rmd160 sha sha1 aes-128-cbc \ aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc aes-256-ecb \ base64 bf bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc \ camellia-128-ecb camellia-192-cbc camellia-192-ecb \ camellia-256-cbc camellia-256-ecb cast cast-cbc cast5-cbc \ cast5-cfb cast5-ecb cast5-ofb des des-cbc des-cfb des-ecb \ des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 \ des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \ rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \ rc4-40'; if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=($( compgen -W "$commands" -- "$cur" )); else command=${COMP_WORDS[1]}; case $prev in -CA | -CAfile | -CAkey | -CAserial | -cert | -certfile | -config | -content | -dcert | -dkey | -dhparam | -extfile | -in | -inkey | -kfile | -key | -keyout | -out | -oid | -prvrify | -rand | -recip | -revoke | -sess_in | -sess_out | -spkac | -sign | -signkey | -signer | -signature | -ss_cert | -untrusted | -verify) _filedir; return 0 ;; -outdir | -CApath) _filedir -d; return 0 ;; -name | -crlexts | -extensions) _openssl_sections; return 0 ;; -inform | -outform | -keyform | -certform | -CAform | -CAkeyform | -dkeyform | -dcertform) formats='DER PEM'; case $command in x509) formats="$formats NET" ;; smime) formats="$formats SMIME" ;; esac; COMPREPLY=($( compgen -W "$formats" -- "$cur" )); return 0 ;; -connect) _known_hosts_real "$cur"; return 0 ;; -starttls) COMPREPLY=($( compgen -W 'smtp pop3 imap ftp' -- "$cur" )); return 0 ;; -cipher) COMPREPLY=($( compgen -W "$(openssl ciphers | tr ':' '\n')" -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then case $command in asn1parse) options='-inform -in -out -noout -offset -length -i -oid \ -strparse' ;; ca) options='-verbose -config -name -gencrl -revoke \ -crl_reason -crl_hold -crl_compromise \ -crl_CA_compromise -crldays -crlhours -crlexts \ -startdate -enddate -days -md -policy -keyfile -key \ -passin -cert -selfsig -in -out -notext -outdir \ -infiles -spkac -ss_cert -preserveDN -noemailDN \ -batch -msie_hack -extensions -extfile -engine \ -subj -utf8 -multivalue-rdn' ;; ciphers) options='-v -ssl2 -ssl3 -tls1' ;; crl) options='-inform -outform -text -in -out -noout -hash \ -issuer -lastupdate -nextupdate -CAfile -CApath' ;; crl2pkcs7) options='-inform -outform -in -out -print_certs' ;; dgst) options='-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \ -c -d -hex -binary -out -sign -verify -prverify \ -signature' ;; dsa) options='-inform -outform -in -passin -out -passout -des \ -des3 -idea -text -noout -modulus -pubin -pubout' ;; dsaparam) options='-inform -outform -in -out -noout -text -C -rand \ -genkey' ;; enc) options='-ciphername -in -out -pass -e -d -a -A -k -kfile \ -S -K -iv -p -P -bufsize -debug' ;; dhparam) options='-inform -outform -in -out -dsaparam -noout -text \ -C -2 -5 -rand' ;; gendsa) options='-out -des -des3 -idea -rand' ;; genrsa) options='-out -passout -des -des3 -idea -f4 -3 -rand' ;; pkcs7) options='-inform -outform -in -out -print_certs -text \ -noout' ;; rand) options='-out -rand -base64' ;; req) options='-inform -outform -in -passin -out -passout -text \ -noout -verify -modulus -new -rand -newkey -newkey \ -nodes -key -keyform -keyout -md5 -sha1 -md2 -mdc2 \ -config -x509 -days -asn1-kludge -newhdr -extensions \ -reqexts section' ;; rsa) options='-inform -outform -in -passin -out -passout \ -sgckey -des -des3 -idea -text -noout -modulus -check \ -pubin -pubout -engine' ;; rsautl) options='-in -out -inkey -pubin -certin -sign -verify \ -encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' ;; s_client) options='-connect -verify -cert -certform -key -keyform \ -pass -CApath -CAfile -reconnect -pause -showcerts \ -debug -msg -nbio_test -state -nbio -crlf -ign_eof \ -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \ -bugs -cipher -starttls -engine -tlsextdebug \ -no_ticket -sess_out -sess_in -rand' ;; s_server) options='-accept -context -verify -Verify -crl_check \ -crl_check_all -cert -certform -key -keyform -pass \ -dcert -dcertform -dkey -dkeyform -dpass -dhparam \ -nbio -nbio_test -crlf -debug -msg -state -CApath \ -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 \ -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 -no_dhe \ -bugs -hack -www -WWW -HTTP -engine -tlsextdebug \ -no_ticket -id_prefix -rand' ;; s_time) options='-connect -www -cert -key -CApath -CAfile -reuse \ -new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' ;; sess_id) options='-inform -outform -in -out -text -noout -context \ ID' ;; smime) options='-encrypt -decrypt -sign -verify -pk7out -des \ -des3 -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 \ -in -certfile -signer -recip -inform -passin -inkey \ -out -outform -content -to -from -subject -text -rand' ;; speed) options='-engine' ;; verify) options='-CApath -CAfile -purpose -untrusted -help \ -issuer_checks -verbose -certificates' ;; x509) options='-inform -outform -keyform -CAform -CAkeyform -in \ -out -serial -hash -subject_hash -issuer_hash -subject \ -issuer -nameopt -email -startdate -enddate -purpose \ -dates -modulus -fingerprint -alias -noout -trustout \ -clrtrust -clrreject -addtrust -addreject -setalias \ -days -set_serial -signkey -x509toreq -req -CA -CAkey \ -CAcreateserial -CAserial -text -C -md2 -md5 -sha1 \ -mdc2 -clrext -extfile -extensions -engine' ;; md5 | md4 | md2 | sha1 | sha | mdc2 | ripemd160) options='-c -d' ;; esac; COMPREPLY=($( compgen -W "$options" -- "$cur" )); else if [[ "$command" == speed ]]; then COMPREPLY=($( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 \ idea-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 \ rsa512 rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea \ rc2 des rsa blowfish' -- "$cur" )); else _filedir; fi; fi; fi } _openssl_sections () { local config f; for ((i=2; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == -config ]]; then config=${COMP_WORDS[i+1]}; break; fi; done; if [ -z "$config" ]; then for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf /usr/share/ssl/openssl.cnf; do [ -f $f ] && config=$f && break; done; fi; [ ! -f "$config" ] && return 0; COMPREPLY=($( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" -- "$cur" )) } _pack200 () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -S | --segment-limit | -P | --pass-file | -C | --class-attribute | -F | --field-attribute | -M | --method-attribute | -D | --code-attribute | '-?' | -h | --help | -V | --version | -J) return 0 ;; -E | --effort) COMPREPLY=($( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" )); return 0 ;; -H | --deflate-hint) COMPREPLY=($( compgen -W 'true false keep' -- "$cur" )); return 0 ;; -m | --modification-time) COMPREPLY=($( compgen -W 'latest keep' -- "$cur" )); return 0 ;; -U | --unknown-attribute) COMPREPLY=($( compgen -W 'error strip pass' -- "$cur" )); return 0 ;; -f | --config-file) _filedir properties; return 0 ;; -l | --log-file) COMPREPLY=($( compgen -W '-' -- "$cur" )); _filedir log; return 0 ;; -r | --repack) _filedir jar; return 0 ;; esac; local i pack=false jar=false; for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ )) do case ${COMP_WORDS[i]} in *.pack | *.pack.gz) pack=true ;; *.jar) jar=true ;; esac; done; if ! $pack; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--no-gzip --gzip --strip-debug \ --no-keep-file-order --segment-limit= --effort= \ --deflate-hint= --modification-time= --pass-file= \ --unknown-attribute= --class-attribute= --field-attribute= \ --method-attribute= --code-attribute= --config-file= \ --verbose --quiet --log-file= --help --version -J \ --repack' -- "$cur" )); [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && type compopt &>/dev/null && compopt -o nospace; else _filedir 'pack?(.gz)'; fi; else if ! $jar; then _filedir jar; fi; fi } _parse_help () { $1 ${2:---help} 2>&1 | sed -e '/^[[:space:]]*-/!d' -e 's|[,/]| |g' | awk '{ print $1; if ($2 ~ /^-/) { print $2 } }' | sed -e 's|[<=].*||' } _passwd () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -n | -x | -w | -i | -\? | --help | --usage) return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-k -l --stdin -u -d -n -x -w -i -S \ -? --help --usage' -- "$cur" )); return 0; fi; _allowed_users } _pci_ids () { COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$( PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur" )) } _perl () { local cur prev prefix temp; local optPrefix optSuffix; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev; prefix=""; if [[ "$cur" == -?* ]]; then temp=$cur; prev=${temp:0:2}; cur=${temp:2}; optPrefix=-P$prev; optSuffix=-S/; prefix=$prev; fi; case $prev in -D | -e | -E | -i | -F | -l) return 0 ;; -I | -x) local IFS=' '; _compopt_o_filenames; COMPREPLY=($( compgen -d $optPrefix $optSuffix -- "$cur" )); return 0 ;; -m | -M) temp="${cur#-}"; prefix="$prefix${cur%$temp}"; cur="$temp"; _perlmodules $1; return 0 ;; -V) if [[ $cur == :* ]]; then temp="${cur##+(:)}"; prefix="$prefix${cur%$temp}"; local IFS=' '; COMPREPLY=($( compgen -P "$prefix" -W '$( $1 -MConfig -e "print join \"\\n\", keys %Config::Config" 2>/dev/null )' -- "$temp" )); __ltrim_colon_completions "$prefix$temp"; fi; return 0 ;; -d | -dt) if [[ $cur == :* ]]; then temp="${cur#:}"; prefix="$prefix${cur%$temp}"; cur="Devel::$temp"; _perlmodules $1; fi; return 0 ;; esac; 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; fi } _perldoc () { local cur prev prefix temp; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev; prefix=""; if [[ "$cur" == -?* ]]; then temp=$cur; prev=${temp:0:2}; cur=${temp:2}; prefix=$prev; fi; case $prev in -f) _perlfunctions "$cur"; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- "$cur" )); else if [[ "$cur" != */* ]]; then _perlmodules; COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '$( MANPAGER=/bin/cat PAGER=/bin/cat man perl | \ sed -ne "/perl.*Perl overview/,/perlwin32/p" | \ awk "\$NF=2 { print \$1}" | command grep perl )' -- "$cur" )); fi; _filedir 'p@(l|m|od)'; fi } _perlfunctions () { COMPREPLY=($( compgen -P "$prefix" -W "$( $(dirname $(readlink -f ${BASH_SOURCE[0]}))/helpers/perl functions $cur )" -- "$cur" )) } _perlmodules () { COMPREPLY=($( compgen -P "$prefix" -W "$( $1 $(dirname $(readlink -f ${BASH_SOURCE[0]}))/helpers/perl modules $cur )" -- "$cur" )); __ltrim_colon_completions "$prefix$cur" } _pgids () { COMPREPLY=($( compgen -W '$( command ps axo pgid= )' -- "$cur" )) } _pgrep () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; _pnames; return 0 } _pids () { COMPREPLY=($( compgen -W '$( command ps axo pid= )' -- "$cur" )) } _pkcon () { local i c=1 command; while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}"; case "$i" in --version | --help | --verbose | --nowait | -v | -n | -h | -?) ;; *) command="$i"; break ;; esac; c=$((++c)); done; if [ $c -eq $COMP_CWORD -a -z "$command" ]; then case "${COMP_WORDS[COMP_CWORD]}" in --*=*) COMPREPLY=() ;; --*) __pkconcomp " --version --filter --verbose --help --nowait " ;; -*) __pkconcomp " -v -n -h -? --version --verbose --help --filter --nowait " ;; *) __pkconcomp "$__pkcon_commandlist" ;; esac; return; fi; case "$command" in search) _pkcon_search ;; *) COMPREPLY=() ;; esac } _pkcon_search () { local i c=1 command; while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}"; case "$i" in name | details | group | file) command="$i"; break ;; esac; c=$((++c)); done; if [ $c -eq $COMP_CWORD -a -z "$command" ]; then __pkconcomp "name details group file"; fi; return } _pkg_config () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in --variable | --define-variable | --atleast-version | --atleast-pkgconfig-version | --exact-version | --max-version) return 0 ;; -\? | --help | --version | --usage) return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--version --modversion \ --atleast-pkgconfig-version --libs --static \ --short-errors --libs-only-l --libs-only-other \ --libs-only-L --cflags --cflags-only-I \ --cflags-only-other --variable --define-variable \ --exists --uninstalled --atleast-version \ --exact-version --max-version --list-all --debug \ --print-errors --silence-errors --errors-to-stdout \ --print-provides --print-requires --help --usage' -- "$cur")); else COMPREPLY=($( compgen -W "$( pkg-config --list-all 2>/dev/null | awk '{print $1}' )" -- "$cur" )); fi } _pm_action () { local cur; _get_comp_words_by_ref cur; COMPREPLY=($( compgen -W "--help $( _parse_help "$1" )" -- "$cur" )) } _pm_is_supported () { local cur; _get_comp_words_by_ref cur; COMPREPLY=($( compgen -W '--help --suspend --hibernate --suspend-hybrid' -- "$cur" )) } _pm_powersave () { local cur; _get_comp_words_by_ref cur; COMPREPLY=($( compgen -W "true false" -- "$cur" )) } _pnames () { COMPREPLY=($( compgen -X '' -W '$( command ps axo command= | \ sed -e "s/ .*//" -e "s:.*/::" -e "s/:$//" -e "s/^[[(-]//" \ -e "s/[])]$//" | sort -u )' -- "$cur" )) } _pwck () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-q -r -s' -- "$cur" )); return 0; fi; _filedir } _python () { local prev cur i; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -'?' | -h | --help | -V | --version | -c | -m) return 0 ;; -Q) COMPREPLY=($( compgen -W "old new warn warnall" -- "$cur" )); return 0 ;; -W) COMPREPLY=($( compgen -W "ignore default all module once error" -- "$cur" )); return 0 ;; !(?(*/)python*([0-9.])|-?)) [[ $COMP_CWORD -lt 2 || ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir ;; esac; for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ )) do if [[ ${COMP_WORDS[i]} == -c ]]; then _filedir; fi; done; if [[ "$cur" != -* ]]; then _filedir 'py?([co])'; else COMPREPLY=($( compgen -W "$( _parse_help $1 -h )" -- "$cur" )); fi; return 0 } _qdbus () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; [ -n "$cur" ] && unset COMP_WORDS[${#COMP_WORDS[@]}-1]; COMPREPLY=($( compgen -W '$( command ${COMP_WORDS[@]} 2>/dev/null | \ sed s/\(.*\)// )' -- "$cur" )) } _quota () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --format) _quota_formats; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-F --format -g --group -u --user -v \ --verbose -s --human-readable -p --raw-grace -i --no-autofs -l \ --local-only -A --all-nfs -m --no-mixed-pathnames -q --quiet -Q \ --quiet-refuse -w --no-wrap' -- "$cur" )); else _user_or_group; fi } _quota_formats () { COMPREPLY=($( compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur" )) } _quotacheck () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --format) _quota_formats; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-b --backup -v --verbose -d --debug \ -g --group -u --user -c --create-files -f --force -i \ --interactive -n --use-first-dquot -M --try-remount -m \ --no-remount -R --exclude-root -F --format -a --all' -- "$cur" )); else _filesystems; fi } _quotaoff () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --format) _quota_formats; return 0 ;; -x | --xfs-command) COMPREPLY=($( compgen -W 'delete enforce' -- "$cur" )); return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a --all -v --verbose -u --user \ -g --group -p --print-state -x --xfs-command -F --format' -- "$cur" )); else _filesystems; fi } _quotaon () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --format) _quota_formats; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a --all -v --verbose -u --user \ -g --group -f --off -p --print-state -F --format' -- "$cur" )); else _filesystems; fi } _quote_readline_by_ref () { if [[ ${1:0:1} == "'" ]]; then if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then printf -v $2 %s "${1:1}"; else printf -v $2 %q "${1:1}"; printf -v $2 %q ${!2}; fi; else if [[ ${BASH_VERSINFO[0]} -le 3 && ${1:0:1} == '"' ]]; then printf -v $2 %q "${1:1}"; else printf -v $2 %q "$1"; fi; fi; [[ ${!2:0:1} == '$' ]] && eval $2=${!2} } _realcommand () { type -P "$1" > /dev/null && { if type -p realpath > /dev/null; then realpath "$(type -P "$1")"; else if type -p readlink > /dev/null; then readlink -f "$(type -P "$1")"; else type -P "$1"; fi; fi } } _renice () { local command cur curopt i; COMPREPLY=(); _get_comp_words_by_ref cur; command=$1; i=0; while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do curopt=${COMP_WORDS[COMP_CWORD-$i]}; case "$curopt" in -u) _allowed_users ;; -g) _pgids ;; -p | $command) _pids ;; esac; i=$(( ++i )); done } _reply_compgen_array () { local i wlist; for i in ${!COMPREPLY[*]}; do local q=$(quote "$(printf %q "${COMPREPLY[$i]}")"); wlist+=$q' '; done; local ecur="$cur"; ecur="${ecur//\\/\\\\}"; ecur="${ecur//\'/\'}"; local oldifs=$IFS; IFS=' ' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)'; IFS=$oldifs } _repquota () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --format) _quota_formats; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a --all -v --verbose -s --human-readable \ -c --batch-translation -C --no-batch-translation -t \ --truncate-names -n --no-names -p --raw-grace -i --no-autofs \ -u --user -g --group -F --format' -- "$cur" )); else _filesystems; fi } _rfcomm () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -f | --config) _filedir; return 0 ;; -i) _bluetooth_devices; _bluetooth_adresses; return 0 ;; esac; _get_first_arg; if [ -z $arg ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help -a --raw \ --config -i --auth --encrypt --secure --master' -- "$cur" )); else COMPREPLY=($( compgen -W 'show connect listen watch \ bind release' -- "$cur" )); fi; else _count_args; if [ $args -eq 2 ]; then _bluetooth_devices; else case $arg in connect | bind) if [ $args -eq 3 ]; then _bluetooth_adresses; fi ;; esac; fi; fi } _rl_enabled () { [[ "$( bind -v )" = *$1+([[:space:]])on* ]] } _rmmod () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; _installed_modules "$cur"; return 0 } _root_command () { local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin; local root_command=$1; _command $1 $2 $3 } _route () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; if [ "$prev" = dev ]; then _available_interfaces; return 0; fi; local i found; for opt in add del -host -net netmask metric mss window irtt reject mod dyn reinstate dev default gw; do found=false; for ((i=1; i < ${#COMP_WORDS[@]}-1; i++ )) do [ "${COMP_WORDS[i]}" = "$opt" ] && found=true && break; done; $found || COMPREPLY[${#COMPREPLY[@]}]="$opt"; done; COMPREPLY=($( compgen -W '"${COMPREPLY[@]}"' -- "$cur" )) } _rpcdebug () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -s) _rpcdebug_flags; return 0 ;; -c) _rpcdebug_flags; return 0 ;; -m) COMPREPLY=($( compgen -W 'rpc nfs nfsd nlm' -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-v -h -m -s -c' -- "$cur" )); fi } _rpcdebug_flags () { local i module; for ((i=0; i < ${#COMP_WORDS[@]}; i++ )) do if [[ ${COMP_WORDS[i]} == -m ]]; then module=${COMP_WORDS[i+1]}; fi; done; if [ -n "$module" ]; then COMPREPLY=($( compgen -W "$(rpcdebug -vh 2>&1 | command grep '^'$module' ' | awk '{$1 = ""; print $0}')" -- "$cur" )); fi } _rpm () { local cur prev opts nodig nosig; COMPREPLY=(); _get_comp_words_by_ref cur prev; nodig=""; nosig=""; _rpm_nodigsig; if [ $COMP_CWORD -eq 1 ]; then case $cur in -b*) COMPREPLY=($( compgen -W '-ba -bb -bc -bi -bl -bp -bs' -- "$cur" )) ;; -t*) COMPREPLY=($( compgen -W '-ta -tb -tc -ti -tl -tp -ts' -- "$cur" )) ;; --*) COMPREPLY=($( compgen -W '--help --version --initdb \ --checksig --recompile --rebuild --resign --addsign \ --rebuilddb --showrc --setperms --setugids --tarbuild \ --eval --install --upgrade --query --freshen --erase \ --verify --querytags --rmsource --rmspec --clean \ --import' -- "$cur" )) ;; *) COMPREPLY=($( compgen -W '-b -e -E -F -i -q -t -U -V' -- "$cur" )) ;; esac; return 0; fi; case $prev in --dbpath | --excludepath | --prefix | --relocate | --root) _filedir -d; return 0 ;; --eval | -E) COMPREPLY=($( compgen -W "$( rpm --showrc | sed -ne 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p' )" -- "$cur" )); return 0 ;; --pipe) _compopt_o_filenames; COMPREPLY=($( compgen -c -- "$cur" )); return 0 ;; --rcfile) _filedir; return 0 ;; --specfile) _filedir spec; return 0 ;; --whatprovides) if [[ "$cur" == */* ]]; then _filedir; else local IFS=' '; COMPREPLY=($( compgen -W "$( rpm -qa $nodig $nosig --queryformat='%{providename}\n' )" -- "$cur" )); fi; return 0 ;; --whatrequires) if [[ "$cur" == */* ]]; then _filedir; else local IFS=' '; COMPREPLY=($( compgen -W "$( rpm -qa $nodig $nosig --queryformat='%{requirename}\n' )" -- "$cur" )); fi; return 0 ;; --target) COMPREPLY=($( compgen -W "$( command rpm --showrc | sed -ne 's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p' )" -- "$cur" )); return 0 ;; --define | -D | --fileid | --hdrid | --pkgid) return 0 ;; esac; opts="--define --eval --macros --nodigest --nosignature --rcfile --quiet --pipe --verbose"; case ${COMP_WORDS[1]} in -[iFU]* | --install | --freshen | --upgrade) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --percent --force --test --replacepkgs --replacefiles --root --excludedocs --includedocs --noscripts --ignorearch --dbpath --prefix --ignoreos --nodeps --allfiles --ftpproxy --ftpport --justdb --httpproxy --httpport --noorder --relocate --badreloc --notriggers --excludepath --ignoresize --oldpackage --queryformat --repackage --nosuggests" -- "$cur" )); else _filedir '[rs]pm'; fi ;; -e | --erase) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --allmatches --noscripts --notriggers --nodeps --test --repackage" -- "$cur" )); else _rpm_installed_packages "$nodig" "$nosig"; fi ;; -q* | --query) opts="$opts --changelog --configfiles --conflicts --docfiles --dump --enhances --filesbypkg --filecaps --fileclass --filecolor --fileprovide --filerequire --filesbypkg --info --list --obsoletes --pipe --provides --queryformat --rcfile --requires --scripts --suggests --triggers --xml"; if [[ $COMP_LINE == *\ -@(*([^ -])f|-file )* ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --dbpath --fscontext --last --root --state" -- "$cur" )); else _filedir; fi; else if [[ $COMP_LINE == *\ -@(*([^ -])g|-group )* ]]; then _rpm_groups; else if [[ $COMP_LINE == *\ -@(*([^ -])p|-package )* ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --ftpport --ftpproxy --httpport --httpproxy --nomanifest" -- "$cur" )); else _filedir '[rs]pm'; fi; else if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --all --file --fileid --dbpath --fscontext --ftswalk --group --hdrid --last --package --pkgid --root --specfile --state --triggeredby --whatprovides --whatrequires" -- "$cur" )); else if [[ $COMP_LINE != *\ -@(*([^ -])a|-all )* ]]; then _rpm_installed_packages "$nodig" "$nosig"; fi; fi; fi; fi; fi ;; -K* | --checksig) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --nopgp --nogpg --nomd5" -- "$cur" )); else _filedir '[rs]pm'; fi ;; -[Vy]* | --verify) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --root --dbpath --nodeps --nogroup --nolinkto --nomode --nomtime --nordev --nouser --nofiles --noscripts --nomd5 --querytags --specfile --whatrequires --whatprovides" -- "$cur" )); else if [[ $COMP_LINE == *\ -@(*([^ -])f|-file )* ]]; then _filedir; else if [[ $COMP_LINE == *\ -@(*([^ -])g|-group )* ]]; then _rpm_groups; else if [[ $COMP_LINE == *\ -@(*([^ -])p|-package )* ]]; then _filedir '[rs]pm'; else _rpm_installed_packages "$nodig" "$nosig"; fi; fi; fi; fi ;; -[bt]*) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --short-circuit --timecheck --clean --rmsource --rmspec --test --sign --buildroot --target --nobuild --nodeps --nodirtokens" -- "$cur" )); else if [[ ${COMP_WORDS[1]} == -b* ]]; then _filedir spec; else _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))'; fi; fi ;; --rebuild | --recompile) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts --nodeps --rmsource --rmspec --sign --nodirtokens --target" -- "$cur" )); else _filedir '@(?(no)src.r|s)pm'; fi ;; --tarbuild) _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))' ;; --resign | --addsign) _filedir '[rs]pm' ;; --setperms | --setgids) _rpm_installed_packages "$nodig" "$nosig" ;; --clean | --rmsource | --rmspec) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--clean --rmsource --rmspec' -- "$cur" )); else _filedir spec; fi ;; --import | --dbpath | --root) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--import --dbpath --root' -- "$cur" )); else _filedir; fi ;; esac; return 0 } _rpm_groups () { local IFS=' '; COMPREPLY=($( compgen -W "$( rpm -qa $nodig $nosig --queryformat '%{group}\n' )" -- "$cur" )) } _rpm_installed_packages () { local nodig="$1" nosig="$2"; if [[ -r /var/log/rpmpkgs && /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then COMPREPLY=($( compgen -W "$( sed -ne 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' /var/log/rpmpkgs )" -- "$cur" )); else if type rpmqpack &>/dev/null; then COMPREPLY=($( compgen -W '$( rpmqpack )' -- "$cur" )); else _rpm_nodigsig; COMPREPLY=($( rpm -qa $nodig $nosig --qf='%{NAME} ' "$cur*" )); fi; fi } _rpm_nodigsig () { if [[ -z "$nodig" && -z "$nosig" ]]; then local rpmver; rpmver=$(rpm --version); rpmver=${rpmver##* }; if [[ "$rpmver" > "4.0.4" ]]; then nodig="--nodigest"; fi; if [[ "$rpmver" > "4.0.99" ]]; then nosig="--nosignature"; fi; fi } _rsync () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref -n : cur prev; _expand || return 0; case $prev in --config | --password-file | --include-from | --exclude-from) _filedir; return 0 ;; -T | --temp-dir | --compare-dest) _filedir -d; return 0 ;; -e | --rsh) COMPREPLY=($( compgen -W 'rsh ssh' -- "$cur" )); return 0 ;; --compress-level) COMPREPLY=($( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" )); return 0 ;; esac; case $cur in -*) COMPREPLY=($( compgen -W '--verbose --quiet --no-motd --checksum \ --archive --recursive --relative --no-implied-dirs \ --backup --backup-dir --suffix= --update --inplace --append \ --append-verify --dirs --old-dirs --links --copy-links \ --copy-unsafe-links --safe-links --copy-dirlinks \ --keep-dirlinks --hard-links --perms --executability --chmod= \ --acls --xattrs --owner --group --devices --copy-devices \ --specials --times --omit-dir-times --super --fake-super \ --sparse --dry-run --whole-file --no-whole-file \ --one-file-system --block-size= --rsh= --rsync-path= \ --existing --ignore-existing --remove-source-files --delete \ --delete-before --delete-during --delete-delay --delete-after \ --delete-excluded --ignore-errors --force --max-delete= \ --max-size= --min-size= --partial --partial-dir= \ --delay-updates --prune-empty-dirs --numeric-ids --timeout= \ --contimeout= --ignore-times --size-only --modify-window= \ --temp-dir= --fuzzy --compare-dest= --copy-dest= --link-dest= \ --compress --compress-level= --skip-compress= --cvs-exclude \ --filter= --exclude= --exclude-from= --include= \ --include-from= --files-from= --from0 --protect-args \ --address= --port= --sockopts= --blocking-io --no-blocking-io \ --stats --8-bit-output --human-readable --progress \ --itemize-changes --out-format= --log-file= \ --log-file-format= --password-file= --list-only --bwlimit= \ --write-batch= --only-write-batch= --read-batch= --protocol= \ --iconv= --ipv4 --ipv6 --version --help --daemon --config= \ --no-detach' -- "$cur" )) ;; *:*) if type _scp_remote_files &>/dev/null; then local i shell=ssh; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then shell=${COMP_WORDS[i+1]}; break; fi; done; [ "$shell" = ssh ] && _scp_remote_files; fi ;; *) _known_hosts_real -c -a "$cur"; type _scp_local_files &>/dev/null && _scp_local_files || _filedir ;; esac; return 0 } _rtcwake () { COMPREPLY=(); local cur prev split=false; _get_comp_words_by_ref cur prev; _split_longopt && split=true; case "$prev" in --help | -h | --version | -V | --seconds | -s | --time | -t) return 0 ;; --mode | -m) COMPREPLY=($( compgen -W 'standby mem disk on no off' -- "$cur" )); return 0 ;; --device | -d) COMPREPLY=($( command ls -d /dev/rtc?* 2>/dev/null )); COMPREPLY=($( compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur" )); return 0 ;; esac; $split && return 0; COMPREPLY=($( compgen -W '--device --local --mode --seconds --time --utc \ --verbose --version --help' -- "$cur" )) } _samba_debuglevel () { COMPREPLY=($( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- "$cur" )) } _samba_domains () { if [ -n "${COMP_SAMBA_SCAN:-}" ]; then COMPREPLY=($( compgen -W '$( smbtree -N -D )' -- "$cur" )); fi } _samba_hosts () { if [ -n "${COMP_SAMBA_SCAN:-}" ]; then COMPREPLY=($( compgen -W "$( smbtree -N -S | sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' )" -- $cur )); fi } _samba_resolve_order () { COMPREPLY=($( compgen -W 'lmhosts host wins bcast' -- "$cur" )) } _scp () { local configfile cur prev prefix; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev; _ssh_suboption_check && { COMPREPLY=("${COMPREPLY[@]/%/ }"); return 0 }; case $prev in -l | -P) return 0 ;; -F | -i | -S) _filedir; type compopt &>/dev/null && compopt +o nospace; return 0 ;; -c) _ssh_ciphers; COMPREPLY=("${COMPREPLY[@]/%/ }"); return 0 ;; -o) _ssh_options; return 0 ;; esac; _expand || return 0; if [[ "$cur" == *:* ]]; then _scp_remote_files; return 0; fi; if [[ "$cur" == -F* ]]; then cur=${cur#-F}; prefix=-F; else set -- "${COMP_WORDS[@]}"; while [ $# -gt 0 ]; do if [ "${1:0:2}" = -F ]; then if [ ${#1} -gt 2 ]; then configfile="$(dequote "${1:2}")"; else shift; [ "$1" ] && configfile="$(dequote "$1")"; fi; break; fi; shift; done; case $cur in -*) COMPREPLY=($( compgen -W '-1 -2 -4 -6 -B -C -c -F -i -l -o \ -P -p -q -r -S -v' -- "$cur" )); COMPREPLY=("${COMPREPLY[@]/%/ }"); return 0 ;; */*) ;; *) _known_hosts_real -c -a -F "$configfile" "$cur" ;; esac; fi; _scp_local_files "$prefix"; return 0 } _scp_local_files () { local IFS=' '; local dirsonly=false; if [ "$1" = -d ]; then dirsonly=true; shift; fi; if $dirsonly; then COMPREPLY=("${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/")); else COMPREPLY=("${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/$1/")); fi } _scp_remote_files () { local IFS=' '; cur=${cur/\\:/:}; local userhost=${cur%%?(\\):*}; local path=${cur#*:}; path=$( sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path" ); if [ -z "$path" ]; then path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null); fi; local files; if [ "$1" = -d ]; then files=$( ssh -o 'Batchmode yes' $userhost command ls -aF1d "$path*" 2>/dev/null | sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d' ); else files=$( ssh -o 'Batchmode yes' $userhost command ls -aF1d "$path*" 2>/dev/null | sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ); fi; COMPREPLY=("${COMPREPLY[@]}" $files) } _sdptool () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in --bdaddr) _bluetooth_adresses; return 0 ;; esac; $split && return 0; _get_first_arg; if [ -z $arg ]; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help' -- "$cur" )); else COMPREPLY=($( compgen -W 'search browse records add \ del get setattr setseq' -- "$cur" )); fi; else case $arg in search) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--bdaddr \ --tree --raw --xml' -- "$cur" )); else _bluetooth_services; fi ;; browse | records) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--tree --raw --xml' -- "$cur" )); else _bluetooth_adresses; fi ;; add) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--handle --channel' -- "$cur" )); else _bluetooth_services; fi ;; get) if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--bdaddr \ --tree --raw --xml' -- "$cur" )); fi ;; esac; fi } _service () { local cur prev sysvdir; COMPREPLY=(); _get_comp_words_by_ref cur prev; [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0; [ $COMP_CWORD -gt 2 ] && return 0; if [[ $COMP_CWORD -eq 1 && $prev == "service" ]]; then _services; else [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d; COMPREPLY=($( compgen -W '`sed -e "y/|/ /" \ -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ $sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" )); fi; return 0 } _services () { local sysvdir famdir; [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d; famdir=/etc/xinetd.d; COMPREPLY=($( printf '%s\n' $sysvdir/!(*.rpm@(orig|new|save)|*~|functions) )); if [ -d $famdir ]; then COMPREPLY=("${COMPREPLY[@]}" $( printf '%s\n' $famdir/!(*.rpm@(orig|new|save)|*~) )); fi; COMPREPLY=($( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- "$cur" )) } _setquota () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -F | --format) _quota_formats; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-r --remote -m --no-mixed-pathnames \ -F --format -g --group -u --user -p --prototype -b --batch \ -c --continue-batch -t --edit-period -T --edit-times -a --all' -- "$cur" )); else _count_args; case $args in 1) _user_or_group ;; 2) _filesystems ;; esac; fi } _sftp () { local cur prev configfile; COMPREPLY=(); _get_comp_words_by_ref cur prev; _ssh_suboption_check && return 0; case $prev in -b | -F | -P) _filedir; return 0 ;; -o) _ssh_options; return 0 ;; esac; if [[ "$cur" == -F* ]]; then cur=${cur#-F}; _filedir; COMPREPLY=("${COMPREPLY[@]/#/-F}"); cur=-F$cur; else if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-1 -C -v -B -b -F -o -P -R -S -s' -- "$cur" )); else set -- "${COMP_WORDS[@]}"; while [ $# -gt 0 ]; do if [ "${1:0:2}" = -F ]; then if [ ${#1} -gt 2 ]; then configfile="$(dequote "${1:2}")"; else shift; [ "$1" ] && configfile="$(dequote "$1")"; fi; break; fi; shift; done; _known_hosts_real -a -F "$configfile" "$cur"; fi; fi; return 0 } _sh () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -c) return 0 ;; -o | +o) COMPREPLY=($( compgen -W 'allexport errexit ignoreeof monitor noclobber noglob noexec nolog notify nounset verbose vi xtrace' -- "$cur" )); return 0 ;; esac; local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x"; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W "$opts -c -s" -- "$cur" )); return 0; else if [[ "$cur" == +* ]]; then COMPREPLY=($( compgen -W "${opts//-/+}" -- "$cur" )); return 0; fi; fi; _filedir sh } _shells () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '$( command grep "^[[:space:]]*/" /etc/shells 2>/dev/null )' -- "$cur" )) } _signals () { local i; COMPREPLY=($( compgen -A signal SIG${cur#-} )); for ((i=0; i < ${#COMPREPLY[@]}; i++ )) do COMPREPLY[i]=-${COMPREPLY[i]#SIG}; done } _smartctl () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -q | --quietmode) _smartctl_quietmode ;; -d | --device) _smartctl_device; return 0 ;; -t | --tolerance) _smartctl_tolerance; return 0 ;; -b | --badsum) _smartctl_badsum; return 0 ;; -r | --report) _smartctl_report; return 0 ;; -n | --nocheck) _smartctl_powermode; return 0 ;; -s | --smart | -o | --offlineauto | -S | --saveauto) _smartctl_feature; return 0 ;; -l | --log) _smartctl_log; return 0 ;; -v | --vendorattribute) _smartctl_vendorattribute; return 0 ;; -F | --firmwarebug) _smartctl_firmwarebug; return 0 ;; -P | --presets) _smartctl_presets; return 0 ;; -t | --test) _smartctl_test; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--help --version --info --all --quietmode \ --device --tolerance --badsum --report --nocheck --smart \ --offlineauto --saveauto --health --capabilities --attributes \ --log --vendorattribute --firmwarebug --presets --test --captive \ --abort' -- "$cur" )); else cur=${cur:=/dev/}; _filedir; fi } _smartctl_badsum () { COMPREPLY=($( compgen -W 'warn exit ignore' -- "$cur" )) } _smartctl_device () { local i opts='ata scsi sat marvell hpt cciss'; for ((i=0; i <= 31; i++ )) do opts="$opts 3ware,$i"; done; COMPREPLY=($( compgen -W "$opts" -- "$cur" )) } _smartctl_feature () { COMPREPLY=($( compgen -W 'on off' -- "$cur" )) } _smartctl_firmwarebug () { COMPREPLY=($( compgen -W 'none samsung samsung2 samsung3 swapid' -- "$cur" )) } _smartctl_log () { COMPREPLY=($( compgen -W 'error selftest selective directory' -- "$cur" )) } _smartctl_powermode () { COMPREPLY=($( compgen -W 'never sleep standby idle' -- "$cur" )) } _smartctl_presets () { COMPREPLY=($( compgen -W 'use ignore show showall' -- "$cur" )) } _smartctl_quietmode () { COMPREPLY=($( compgen -W 'errorsonly silent noserial' -- "$cur" )) } _smartctl_report () { COMPREPLY=($( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" )) } _smartctl_test () { COMPREPLY=($( compgen -W 'offline short long conveyance select \ afterselect,on afterselect,off pending scttempint' -- "$cur" )) } _smartctl_tolerance () { COMPREPLY=($( compgen -W 'normal conservative permissive \ verypermissive' -- "$cur" )) } _smartctl_vendorattribute () { COMPREPLY=($( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \ 9,temp 192,emergencyretractcyclect 193,loadunload \ 194,10xCelsius 194,unknown 198,offlinescanuncsectorct \ 200,writeerrorcount 201,detectedtacount 220,temp' -- "$cur" )) } _smbcacls () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -s) _filedir; return 0 ;; -l | --log-basename) _filedir -d; return 0 ;; -d | --debuglevel) _samba_debuglevel; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a -M -D -S -U -C -G --numeric -t \ -h --help -V -s -d --debuglevel -l --log-basename' -- "$cur" )); fi } _smbclient () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -R) _samba_resolve_order; return 0 ;; -t) COMPREPLY=($( compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' -- "$cur" )); return 0 ;; -s | -A | --authentication-file) _filedir; return 0 ;; -l | --log-basename | -D) _filedir -d; return 0 ;; -O) COMPREPLY=($( compgen -W 'SO_KEEPALIVE SO_REUSEADDR \ SO_BROADCAST TCP_NODELAY IPTOS_LOWDELAY \ IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF \ SO_SNDLOWAT SO_RCVLOWAT' -- "$cur" )); return 0 ;; -T) COMPREPLY=($( compgen -W 'c x I X F b g q r N a' -- "$cur" )); return 0 ;; -W | --workgroup) _samba_domains; return 0 ;; -d | --debuglevel) _samba_debuglevel; return 0 ;; -p | --port | -M | -I | -b | -U | --user | -n | -i | -T | -c) return 0 ;; -\? | --help | -V | --version) return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-b -d -L -U -I -M -m -A -N -i -O \ -p -R -s -k -P -c -D -W -l -E --debuglevel \ --log-basename --workgroup' -- "$cur" )); fi } _smbcquotas () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -s | -A | --authentication-file) _filedir; return 0 ;; -l | --log-basename) _filedir -d; return 0 ;; -d | --debuglevel) _samba_debuglevel; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-u -L -F -S -n -t -v -h --help -V \ -s --debuglevel --log-basename -N -k \ --authentication-file --user' -- "$cur" )); fi } _smbget () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -o | -f | --outputfile | --rcfile) _filedir; return 0 ;; -d | --debuglevel) _samba_debuglevel; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a --guest -r --resume -R --recursive -u \ --username -p --password -w --workgroup -n --nonprompt -d \ --debuglevel -D --dots -P --keep-permissions -o --outputfile -f \ --rcfile -q --quiet -v --verbose -b --blocksize -? --help --usage' -- "$cur" )); fi } _smbpasswd () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -r) _samba_hosts; return 0 ;; -R) _samba_resolve_order; return 0 ;; -c) _filedir; return 0 ;; -D) _samba_debuglevel; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a -c -x -d -e -D -n -r -R -m -U -h \ -s -w -W -i -L' -- "$cur" )); fi } _smbtar () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -r | -t) _filedir tar; return 0 ;; -s) _samba_hosts; return 0 ;; -l) _samba_debuglevel; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-r -i -a -v -s -p -x -X -N -b -d -l -u -t' -- "$cur" )); fi } _smbtree () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -s | -A | --authentication-file) _filedir; return 0 ;; -l | --log-basename) _filedir -d; return 0 ;; -d | --debuglevel) _samba_debuglevel; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-b -D -S -V -s -d --debuglevel -l \ --log-basename -N -k -A --authentication-file -U --user\ -h --help' -- "$cur" )); fi } _split_longopt () { if [[ "$cur" == --?*=* ]]; then prev="${cur%%?(\\)=*}"; cur="${cur#*=}"; return 0; fi; return 1 } _sqlite3 () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; local dbexts='@(sqlite?(3)|?(s?(3))db)'; case $prev in -help | -version | -separator | -nullvalue | *.$dbexts) return 0 ;; -init) _filedir; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-help -init -echo -header -noheader -bail -interactive -batch -column -csv -html -line -list -separator -nullvalue -version' -- "$cur" )); return 0; fi; _filedir $dbexts } _ssh () { local cur prev configfile; local -a config; COMPREPLY=(); _get_comp_words_by_ref -n : cur prev; _ssh_suboption_check && return 0; case $prev in -F | -i | -S) _filedir; return 0 ;; -c) _ssh_ciphers; return 0 ;; -m) _ssh_macs; return 0 ;; -l) COMPREPLY=($( compgen -u -- "$cur" )); return 0 ;; -o) _ssh_options; return 0 ;; -w) _available_interfaces; return 0 ;; -b) _ssh_bindaddress; return 0 ;; esac; if [[ "$cur" == -F* ]]; then cur=${cur#-F}; _filedir; COMPREPLY=("${COMPREPLY[@]/#/-F}"); cur=-F$cur; else if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-1 -2 -4 -6 -A -a -C -f -g -K -k -M \ -N -n -q -s -T -t -V -v -X -v -Y -y -b -b -c -D -e -F \ -i -L -l -m -O -o -p -R -S -w' -- "$cur" )); else set -- "${COMP_WORDS[@]}"; while [ $# -gt 0 ]; do if [ "${1:0:2}" = -F ]; then if [ ${#1} -gt 2 ]; then configfile="$(dequote "${1:2}")"; else shift; [ "$1" ] && configfile="$(dequote "$1")"; fi; break; fi; shift; done; _known_hosts_real -a -F "$configfile" "$cur"; if [ $COMP_CWORD -ne 1 ]; then _compopt_o_filenames; COMPREPLY=("${COMPREPLY[@]}" $( compgen -c -- "$cur" )); fi; fi; fi; return 0 } _ssh_bindaddress () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( PATH="$PATH:/sbin" ifconfig -a | sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" -- "$cur" )) } _ssh_ciphers () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '3des-cbc aes128-cbc \ aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr arcfour128 \ arcfour256 arcfour blowfish-cbc cast128-cbc' -- "$cur" )) } _ssh_copy_id () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -i) _filedir; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-i' -- "$cur" )); else _known_hosts_real -a "$cur"; fi; return 0 } _ssh_macs () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -W 'hmac-md5 hmac-sha1 \ umac-64@openssh.com hmac-ripemd160 hmac-sha1-96 hmac-md5-96' -- "$cur" )) } _ssh_options () { type compopt &>/dev/null && compopt -o nospace; COMPREPLY=($( compgen -S = -W 'AddressFamily BatchMode BindAddress \ ChallengeResponseAuthentication CheckHostIP Cipher Ciphers \ ClearAllForwardings Compression CompressionLevel ConnectionAttempts \ ConnectTimeout ControlMaster ControlPath DynamicForward EscapeChar \ ExitOnForwardFailure ForwardAgent ForwardX11 ForwardX11Trusted \ GatewayPorts GlobalKnownHostsFile GSSAPIAuthentication \ GSSAPIDelegateCredentials HashKnownHosts Host HostbasedAuthentication \ HostKeyAlgorithms HostKeyAlias HostName IdentityFile IdentitiesOnly \ KbdInteractiveDevices LocalCommand LocalForward LogLevel MACs \ NoHostAuthenticationForLocalhost NumberOfPasswordPrompts \ PasswordAuthentication PermitLocalCommand Port \ PreferredAuthentications Protocol ProxyCommand PubkeyAuthentication \ RekeyLimit RemoteForward RhostsRSAAuthentication RSAAuthentication \ SendEnv ServerAliveInterval ServerAliveCountMax SmartcardDevice \ StrictHostKeyChecking TCPKeepAlive Tunnel TunnelDevice \ UsePrivilegedPort User UserKnownHostsFile VerifyHostKeyDNS \ VisualHostKey XAuthLocation' -- "$cur" )) } _ssh_suboption () { local prev=${1%%=*} cur=${1#*=}; case $prev in BatchMode | ChallengeResponseAuthentication | CheckHostIP | ClearAllForwardings | Compression | ExitOnForwardFailure | ForwardAgent | ForwardX11 | ForwardX11Trusted | GatewayPorts | GSSAPIAuthentication | GSSAPIKeyExchange | GSSAPIDelegateCredentials | GSSAPITrustDns | HashKnownHosts | HostbasedAuthentication | IdentitiesOnly | KbdInteractiveAuthentication | KbdInteractiveDevices | NoHostAuthenticationForLocalhost | PasswordAuthentication | PubkeyAuthentication | RhostsRSAAuthentication | RSAAuthentication | StrictHostKeyChecking | TCPKeepAlive | UsePrivilegedPort | VerifyHostKeyDNS | VisualHostKey) COMPREPLY=($( compgen -W 'yes no' -- "$cur")) ;; AddressFamily) COMPREPLY=($( compgen -W 'any inet inet6' -- "$cur" )) ;; BindAddress) _ssh_bindaddress ;; Cipher) COMPREPLY=($( compgen -W 'blowfish des 3des' -- "$cur" )) ;; Protocol) COMPREPLY=($( compgen -W '1 2 1,2 2,1' -- "$cur" )) ;; Tunnel) COMPREPLY=($( compgen -W 'yes no point-to-point ethernet' -- "$cur" )) ;; PreferredAuthentications) COMPREPLY=($( compgen -W 'gssapi-with-mic host-based \ publickey keyboard-interactive password' -- "$cur" )) ;; MACs) _ssh_macs ;; Ciphers) _ssh_ciphers ;; esac; return 0 } _ssh_suboption_check () { local cureq=`_get_cword :=` preveq=`_get_pword :=`; if [[ $cureq == *=* && $preveq == -o ]]; then _ssh_suboption $cureq; return $?; fi; return 1 } _sysctl () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; COMPREPLY=($( compgen -W "$( PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null )" -- "$cur" )); return 0 } _systemctl () { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}; local verb comps; local -A OPTS=([STANDALONE]='--all -a --defaults --fail --ignore-dependencies --failed --force -f --full --global --help -h --no-ask-password --no-block --no-reload --no-wall --order --require --quiet -q --system --user --version' [ARG]='--kill-mode --kill-who --property -p --signal -s --type -t'); if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --signal | -s) comps=$(compgen -A signal | grep '^SIG' | grep -Ev 'RTMIN|RTMAX|JUNK') ;; --type | -t) comps='automount device mount path service snapshot socket swap target timer' ;; --kill-who) comps='all control main' ;; --kill-mode) comps='control-group process' ;; --property | -p) comps='' ;; esac; COMPREPLY=($(compgen -W "$comps" -- "$cur")); return 0; fi; if [[ "$cur" = -* ]]; then COMPREPLY=($(compgen -W "${OPTS[*]}" -- "$cur")); return 0; fi; local -A VERBS=([ALL_UNITS]='enable disable is-active is-enabled status show' [FAILED_UNITS]='reset-failed' [STARTABLE_UNITS]='start restart reload-or-restart' [STOPPABLE_UNITS]='stop kill try-restart condrestart' [ISOLATABLE_UNITS]='isolate' [RELOADABLE_UNITS]='reload reload-or-try-restart force-reload' [JOBS]='cancel' [SNAPSHOTS]='delete' [ENVS]='set-environment unset-environment' [STANDALONE]='daemon-reexec daemon-reload default dot dump emergency exit halt kexec list-jobs list-units poweroff reboot rescue show-environment' [NAME]='snapshot load'); local verb; for ((i=0; $i <= $COMP_CWORD; i++)) do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG}]}; then verb=${COMP_WORDS[i]}; break; fi; done; if [[ -z $verb ]]; then comps="${VERBS[*]}"; else if __contains_word "$verb" ${VERBS[ALL_UNITS]}; then comps=$( __get_all_units ); else if __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then comps=$( __filter_units_by_property CanStart yes $( __get_inactive_units | grep -Ev '\.(device|snapshot)$' )); else if __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then comps=$( __filter_units_by_property CanStop yes $( __get_active_units ) ); else if __contains_word "$verb" ${VERBS[RELOADABLE_UNITS]}; then comps=$( __filter_units_by_property CanReload yes $( __get_active_units ) ); else if __contains_word "$verb" ${VERBS[ISOLATABLE_UNITS]}; then comps=$( __filter_units_by_property AllowIsolate yes $( __get_all_units ) ); else if __contains_word "$verb" ${VERBS[FAILED_UNITS]}; then comps=$( __get_failed_units ); else if __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[NAME]}; then comps=''; else if __contains_word "$verb" ${VERBS[JOBS]}; then comps=$( systemctl list-jobs | awk '{print $1}' ); else if __contains_word "$verb" ${VERBS[SNAPSHOTS]}; then comps=$( systemctl list-units --type snapshot --full --all | awk '{print $1}' ); else if __contains_word "$verb" ${VERBS[ENVS]}; then comps=$( systemctl show-environment | sed 's_\([^=]\+=\).*_\1_' ); compopt -o nospace; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; COMPREPLY=($(compgen -W "$comps" -- "$cur")); return 0 } _tar () { local cur ext regex tar untar; COMPREPLY=(); _get_comp_words_by_ref cur; if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=($( compgen -W 'c t x u r d A' -- "$cur" )); return 0; fi; case ${COMP_WORDS[1]} in ?(-)[cr]*f) _filedir; return 0 ;; +([^IZzJjy])f) ext='@(@(tar|gem|spkg)?(.@(Z|[gx]z|bz?(2)|lzma))|t@([glx]z|bz?(2)))'; regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[gx]z\|bz?(2)\|lzma\)\)\?\|t\([glx]z\|bz2\?\)\)' ;; *[Zz]*f) ext='@(t?(ar.)|gem.|spkg.)@(gz|Z)'; regex='\(t\(ar\.\)\?\|gem\.\|spkg\.\)\(gz\|Z\)' ;; *[Ijy]*f) ext='@(@(t?(ar.)|gem.)bz?(2)|spkg)'; regex='\(\(t\(ar\.\)\?\|gem\.\)bz2\?\|spkg\)' ;; *[J]*f) ext='@(t?(ar.)|gem.|spkg.)@(lz?(ma)|xz)'; regex='\(t\(ar\.\)\?\|gem\.\|spkg\.\)\(lzma\|xz\)\?' ;; *) _filedir; return 0 ;; esac; if [[ "$COMP_LINE" == *$ext' ' ]]; then tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"$COMP_LINE" ); untar=t${COMP_WORDS[1]//[^Izjyf]/}; local IFS=' '; COMPREPLY=($( compgen -W "$( printf '%s\n' $( tar $untar $tar 2>/dev/null ) )" -- "$cur" )); return 0; fi; _filedir "$ext"; return 0 } _tcpdump () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -r | -w | -F) _filedir; return 0 ;; -i) _available_interfaces -a; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-a -d -e -f -l -n -N -O -p \ -q -R -S -t -u -v -x -C -F -i -m -r -s -T -w -E' -- "$cur" )); fi } _tilde () { local result=0; if [[ ${1:0:1} == "~" && $1 == ${1//\/} ]]; then _compopt_o_filenames; COMPREPLY=($( compgen -P '~' -u "${1#\~}" )); result=${#COMPREPLY[@]}; fi; return $result } _tune2fs () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -c | -C | -E | -i | -J | -L | -m | -r | -T) return 0 ;; -e) COMPREPLY=($( compgen -W 'continue remount-ro panic' -- "$cur" )); return 0 ;; -g) _gids; COMPREPLY=($( compgen -g -W '${COMPREPLY[@]}' -- "$cur" )); return 0 ;; -M) _filedir -d ;; -o) local -a opts=(^debug ^bsdgroups ^user_xattr ^acl ^uid16 ^journal_data ^journal_data_ordered ^journal_data_writeback); COMPREPLY=($( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" )); return 0 ;; -O) local -a opts=(^dir_index ^dir_nlink ^extent ^extra_isize ^filetype ^flex_bg ^has_journal ^huge_file ^large_file ^resize_inode ^sparse_super ^uninit_bg); COMPREPLY=($( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" )); return 0 ;; -u) _uids; COMPREPLY=($( compgen -u -W '${COMPREPLY[@]}' -- "$cur" )); return 0 ;; -U) COMPREPLY=($( compgen -W 'clear random time' -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-c -C -e -E -f -g -i -j -J -l -L -m -M -o -O -r -T -u -U' -- "$cur" )); fi; cur=${cur:=/dev/}; _filedir } _uids () { if type getent &>/dev/null; then COMPREPLY=($( compgen -W '$( getent passwd | cut -d: -f3 )' -- "$cur" )); else if type perl &>/dev/null; then COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- "$cur" )); else COMPREPLY=($( compgen -W '$( cut -d: -f3 /etc/passwd )' -- "$cur" )); fi; fi } _umount () { local cur; _get_comp_words_by_ref cur; COMPREPLY=(); if [[ $(uname -s) = Linux && -r /proc/mounts ]]; then _linux_fstab < /proc/mounts; else local IFS=' '; COMPREPLY=($( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" )); fi; return 0 } _unpack200 () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in '-?' | -h | --help | -V | --version | -J) return 0 ;; -H | --deflate-hint) COMPREPLY=($( compgen -W 'true false keep' -- "$cur" )); return 0 ;; -l | --log-file) COMPREPLY=($( compgen -W '-' -- "$cur" )); _filedir log; return 0 ;; esac; local i pack=false jar=false; for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ )) do case ${COMP_WORDS[i]} in *.pack | *.pack.gz) pack=true ;; *.jar) jar=true ;; esac; done; if ! $pack; then if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--deflate-hint= --remove-pack-file \ --verbose --quiet --log-file= --help --version' -- "$cur" )); [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && type compopt &>/dev/null && compopt -o nospace; else _filedir 'pack?(.gz)'; fi; else if ! $jar; then _filedir jar; fi; fi } _unrar () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu \ -dh -ep -f -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta \ -tb -tn -to -u -v -ver -vp -x -x@ -y' -- "$cur" )); else if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=($( compgen -W 'e l lb lt p t v vb vt x' -- "$cur" )); else _filedir rar; fi; fi } _update_alternatives () { local cur prev mode args i; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in --altdir | --admindir) _filedir -d; return 0 ;; --help | --usage | --version) return 0 ;; esac; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then mode=${COMP_WORDS[i]}; args=$(($COMP_CWORD - i)); break; fi; done; case $mode in --install) case $args in 1 | 3) _filedir ;; 2) _installed_alternatives ;; 4) ;; *) case $((args % 4)) in 0 | 2) _filedir ;; 1) COMPREPLY=($( compgen -W '--slave' -- "$cur" )) ;; 3) _installed_alternatives ;; esac ;; esac ;; --remove | --set) case $args in 1) _installed_alternatives ;; 2) _filedir ;; esac ;; --auto | --remove-all | --display | --config) _installed_alternatives ;; *) COMPREPLY=($( compgen -W '--verbose --quiet --help --version \ --altdir --admindir --install --remove --auto --display \ --config --set' -- "$cur" )) ;; esac } _upvar () { if unset -v "$1"; then if (( $# == 2 )); then eval $1=\"\$2\"; else eval $1=\(\"\${@:2}\"\); fi; fi } _upvars () { if ! (( $# )); then echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname" "value] | [-aN varname [value ...]] ..." 1>&2; return 2; fi; while (( $# )); do case $1 in -a*) [[ -n ${1#-a} ]] || { echo "bash: ${FUNCNAME[0]}: \`$1': missing" "number specifier" 1>&2; return 1 }; printf %d "${1#-a}" &>/dev/null || { echo "bash:" "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2; return 1 }; [[ -n "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && shift $((${1#-a} + 2)) || { echo "bash: ${FUNCNAME[0]}:" "\`$1${2+ }$2': missing argument(s)" 1>&2; return 1 } ;; -v) [[ -n "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && shift 3 || { echo "bash: ${FUNCNAME[0]}: $1: missing" "argument(s)" 1>&2; return 1 } ;; *) echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2; return 1 ;; esac; done } _usb_ids () { COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$( PATH="$PATH:/sbin" lsusb | awk '{print $6}' )" -- "$cur" )) } _user_at_host () { local cur; COMPREPLY=(); _get_comp_words_by_ref -n : cur; if [[ $cur == *@* ]]; then _known_hosts_real "$cur"; else COMPREPLY=($( compgen -u -- "$cur" )); fi; return 0 } _user_or_group () { local i; for ((i=1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == -g ]]; then COMPREPLY=($( compgen -g -- "$cur" )); return 0; fi; done; COMPREPLY=($( compgen -u -- "$cur" )) } _useradd () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -c | --comment | -h | --help | -e | --expiredate | -f | --inactive | -k | --key | -p | --password | -u | --uid | -Z | --selinux-user) return 0 ;; -b | --base-dir | -d | --home | -k | --skel) _filedir -d; return 0 ;; -g | --gid) _gids; COMPREPLY=($( compgen -W '${COMPREPLY[@]} $( compgen -g )' -- "$cur" )); return 0 ;; -G | --groups) COMPREPLY=($( compgen -g -- "$cur" )); return 0 ;; -s | --shell) _shells; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--base-dir --comment --home-dir --defaults \ --expiredate --inactive --gid --groups --help --skel --key \ --no-log-init --create-home --no-create-home --no-user-group \ --non-unique --password --system --shell --uid --user-group \ --selinux-user' -- "$cur" )); return 0; fi } _userdel () { local cur; COMPREPLY=(); _get_comp_words_by_ref cur; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--force --help --remove' -- "$cur" )); return 0; fi; COMPREPLY=($( compgen -u -- "$cur" )) } _usergroup () { if [[ $cur = *\\\\* || $cur = *:*:* ]]; then return; else if [[ $cur = *\\:* ]]; then local prefix; prefix=${cur%%*([^:])}; prefix=${prefix//\\}; local mycur="${cur#*[:]}"; if [[ $1 == -u ]]; then _allowed_groups "$mycur"; else local IFS=' '; COMPREPLY=($( compgen -g -- "$mycur" )); fi; COMPREPLY=($( compgen -P "$prefix" -W "${COMPREPLY[@]}" )); else if [[ $cur = *:* ]]; then local mycur="${cur#*:}"; if [[ $1 == -u ]]; then _allowed_groups "$mycur"; else local IFS=' '; COMPREPLY=($( compgen -g -- "$mycur" )); fi; else if [[ $1 == -u ]]; then _allowed_users "$cur"; else local IFS=' '; COMPREPLY=($( compgen -u -- "$cur" )); fi; fi; fi; fi } _usermod () { local cur prev split=false; COMPREPLY=(); _get_comp_words_by_ref cur prev; _split_longopt && split=true; case $prev in -c | --comment | -d | --home | -e | --expiredate | -f | --inactive | -h | --help | -l | --login | -p | --password | -u | --uid | -Z | --selinux-user) return 0 ;; -g | --gid) _gids; COMPREPLY=($( compgen -W '${COMPREPLY[@]} $( compgen -g )' -- "$cur" )); return 0 ;; -G | --groups) COMPREPLY=($( compgen -g -- "$cur" )); return 0 ;; -s | --shell) _shells; return 0 ;; esac; $split && return 0; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--append --comment --home --expiredate \ --inactive --gid --groups --help --login --lock --move-home \ --non-unique --password --shell --uid --unlock --selinux-user' -- "$cur" )); return 0; fi; COMPREPLY=($( compgen -u -- "$cur" )) } _vipw () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -h | --help) return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--group --help --passwd \ --quiet --shadow' -- "$cur" )); return 0; fi } _vpnc () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in --pfs) COMPREPLY=($( compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur" )); return 0 ;; --pfs) COMPREPLY=($( compgen -W 'dh1 dh2 dh5' -- "$cur" )); return 0 ;; --pid-file | --script) _filedir; return 0 ;; --gateway) _known_hosts_real "$cur"; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--version --print-config --help \ --long-help --gateway --id --username --udp --domain \ --xauth-inter --script --dh --pfs --enable-1des \ --application-version --ifname --debug --no-detach \ --pid-file --local-port --udp-port --disable-natt \ --non-inter' -- "$cur" )); else COMPREPLY=($( compgen -W '$( command ls /etc/vpnc )' -- "$cur" )); fi } _xhost () { local cur; _get_comp_words_by_ref cur; case $cur in +*) _known_hosts_real -p+ "${cur:1}" ;; -*) _known_hosts_real -p- "${cur:1}" ;; *) _known_hosts_real "$cur" ;; esac; return 0 } _xmllint () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -o | --output) _filedir; return 0 ;; --path | --dtdvalidfpi | --maxmem | --encode | --pattern) return 0 ;; --dtdvalid) _filedir 'dtd?(.gz)'; return 0 ;; --relaxng) _filedir 'rng?(.gz)'; return 0 ;; --schema) _filedir 'xsd?(.gz)'; return 0 ;; --schematron) _filedir 'sch?(.gz)'; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '$( xmllint --help 2>&1 | \ sed -ne "s/^[[:space:]]*\(--[^[:space:]:]*\).*/\1/p" ) \ -o' -- "$cur" )); return 0; fi; _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp)?(.gz)' } _xmlwf () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in -d) _filedir -d; return 0 ;; -e) COMPREPLY=($( compgen -W 'US-ASCII UTF-8 UTF-16 \ ISO-8859-1' -- "$cur" )); return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-c -d -e -m -n -p -r -s -t -v -w \ -x' -- "$cur" )); return 0; fi; _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp)' } _xmodmap () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -display | -e) return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-display -help -grammar -verbose -quiet -n -e -pm -pk -pke -pp' -- "$cur" )); return 0; fi; _filedir } _xrandr () { local cur prev output modes; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in --output) local outputs=$(xrandr|awk '/connected/ {print $1}'); COMPREPLY=($(compgen -W "$outputs" -- "$cur")); return 0 ;; --mode) for ((i = 1; i < COMP_CWORD; i++ )) do if [[ "${COMP_WORDS[i]}" == "--output" ]]; then output=${COMP_WORDS[i+1]}; break; fi; done; modes=$(xrandr|sed -e "1,/$output/ d" -e "/connected/,$ d"|awk '{print $1}'); COMPREPLY=($( compgen -W "$modes" -- "$cur")); return 0 ;; esac; case $cur in *) COMPREPLY=($(compgen -W '-display -help --orientation --query \ --size --rate --version -x -y --screen --verbose --dryrun \ --prop --fb --fbmm --dpi --output --auto --mode --preferred \ --pos --reflect --rotate --left-of --right-of --above --below \ --same-as --set --off --crtc --newmode --rmmode --addmode \ --delmode' -- "$cur")); return 0 ;; esac; return 0 } _xrdb () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; case $prev in -backup | -display | -help) return 0 ;; -cpp | -edit) _filedir; return 0 ;; esac; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '-help -display -all -global -screen -screens -n -quiet -cpp -nocpp -symbols -query -load -override -merge -remove -retain -edit -backup' -- "$cur" )); return 0; fi; _filedir } _xsltproc () { local cur prev; COMPREPLY=(); _get_comp_words_by_ref cur prev; case $prev in --output | -o) _filedir; return 0 ;; --maxdepth) return 0 ;; --encoding) COMPREPLY=($( compgen -W "$( iconv -l | sed -e '/^UTF[1378]/d' -e '/^ISO[0-9_]/d' -e '/^8859/d' -e 's/\/.*//')" -- "$cur" )); return 0 ;; --param | --stringparam) return 0 ;; --path) _filedir -d; return 0 ;; --writesubtree) _filedir -d; return 0 ;; esac; [[ $COMP_CWORD -gt 2 && `_get_cword '' 2` == --?(string)param ]] && return 0; if [[ "$cur" == -* ]]; then _longopt xsltproc; else _filedir '@(xsl|xslt|xml)'; fi } _xz () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--compress --decompress --test --list \ --keep --force --stdout --suffix --files --files0 --format --check \ -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 --fast --best --extreme --memory \ --lzma1 --lzma2 --x86 --powerpc --ia64 --arm --armthumb --sparc \ --delta --quiet --verbose --no-warn --help --long-help --version' -- "$cur" )); return 0; fi; local split=false; _split_longopt && split=true; local xspec="*.@(xz|lzma|txz|tlz)"; case $prev in --decompress | --list | --test | -!(-*)[dlt]*) xspec="!"$xspec ;; --files | --files0) _filedir; return 0 ;; -C | --check) COMPREPLY=($( compgen -W 'crc32 crc64 sha256' -- "$cur" )); return 0 ;; -F | --format) COMPREPLY=($( compgen -W 'auto xz lzma raw' -- "$cur" )); return 0 ;; -M | --memory | -S | --suffix | --delta | --lzma1 | --lzma2) return 0 ;; -h | --help | -H | --long-help | -V | --version) return 0 ;; esac; $split && return 0; _expand || return 0; local IFS=' '; _compopt_o_filenames; COMPREPLY=($( compgen -f -X "$xspec" -- "$cur" ) $( compgen -d -- "$cur" )) } _xzdec () { COMPREPLY=(); local cur prev; _get_comp_words_by_ref cur prev; if [[ "$cur" == -* ]]; then COMPREPLY=($( compgen -W '--memory --help --version' -- "$cur" )); return 0; fi; local split=false; _split_longopt && split=true; case $prev in -M | --memory) return 0 ;; -h | --help | -V | --version) return 0 ;; esac; $split && return 0; _filedir xz } _ypmatch () { local cur map cmd; COMPREPLY=(); _get_comp_words_by_ref cur; cmd=${1##*/}; [[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0; [[ $cmd == ypmatch && $COMP_CWORD -gt 2 ]] && return 0; if [[ $cmd == ypmatch && $COMP_CWORD -eq 1 && ${#COMP_WORDS[@]} -eq 3 ]]; then map=${COMP_WORDS[2]}; COMPREPLY=($( compgen -W '$( ypcat $map | \ cut -d':' -f 1 )' -- "$cur")); else [[ $cmd == ypmatch && $COMP_CWORD -ne 2 ]] && return 0; COMPREPLY=($( compgen -W '$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur")); fi; return 0 } _yu_builddep () { COMPREPLY=(); _yum_complete_baseopts "$2" "$3" && return 0; if [[ $2 == -* ]]; then COMPREPLY=($( compgen -W '$( _yum_baseopts 2>/dev/null )' -- "$2" )); return 0; fi; COMPREPLY=($( compgen -f -o plusdirs -X "!*.spec" -- "$2" )); [[ $2 != */* && $2 != ~* ]] && _yum_list all "$2" 2> /dev/null } _yu_debuginfo_install () { COMPREPLY=(); _yum_complete_baseopts "$2" "$3" && return 0; if [[ $2 == -* ]]; then COMPREPLY=($( compgen -W '$( _yum_baseopts 2>/dev/null ) --no-debuginfo-plugin' -- "$2" )); return 0; fi; _yum_list all "$2" } _yu_package_cleanup () { COMPREPLY=(); _yum_complete_baseopts "$2" "$3" 2> /dev/null && return 0; case "$3" in --leaf-regex | --qf | --queryformat) return 0 ;; --count) COMPREPLY=($( compgen -W '1 2 3 4 5 6 7 8 9' -- "$2" )); return 0 ;; esac; COMPREPLY=($( compgen -W '$( _yum_baseopts 2>/dev/null ) --problems --queryformat --orphans --dupes --cleandupes --noscripts --leaves --all --leaf-regex --exclude-devel --exclude-bin --oldkernels --count --keepdevel' -- "$2" )) } _yu_repo_graph () { COMPREPLY=(); case "$3" in -h | --help) return 0 ;; --repoid) _yum_repolist all "$2" 2> /dev/null; return 0 ;; -c) COMPREPLY=($( compgen -f -o plusdirs -X '!*.conf' -- "$2" )); return 0 ;; esac; COMPREPLY=($( compgen -W '--help --repoid -c' -- "$2" )) } _yu_repo_rss () { COMPREPLY=(); case "$3" in -h | --help | -l | -t | -d | -r | -a) return 0 ;; -f) COMPREPLY=($( compgen -f -o plusdirs -X '!*.xml' -- "$2" )); return 0 ;; -c) COMPREPLY=($( compgen -f -o plusdirs -X '!*.conf' -- "$2" )); return 0 ;; esac; COMPREPLY=($( compgen -W '--help -f -l -t -d -r --tempcache -g -a -c' -- "$2" )); [[ "$2" == -* ]] || _yum_repolist all "$2" 2> /dev/null || return 0 } _yu_repoclosure () { COMPREPLY=(); case "$3" in -h | --help | -a | --arch | --basearch | --repofrompath) return 0 ;; -c | --config) COMPREPLY=($( compgen -f -o plusdirs -X '!*.conf' -- "$2" )); return 0 ;; -l | --lookaside | -r | --repoid) _yum_repolist all "$2" 2> /dev/null; return 0 ;; -p | --pkg) _yum_list all "$2" 2> /dev/null; return 0 ;; -g | --group) _yum_grouplist "" "$2" 2> /dev/null; return 0 ;; esac; COMPREPLY=($( compgen -W '--help --config --arch --basearch --builddeps --lookaside --repoid --tempcache --quiet --newest --repofrompath --pkg --group' -- "$2" )) } _yu_repodiff () { COMPREPLY=(); case "$3" in -h | --help | --version | -n | --new | -o | --old | -a | --archlist) return 0 ;; esac; COMPREPLY=($( compgen -W '--version --help --new --old --quiet --archlist --size --simple' -- "$2" )) } _yu_repomanage () { COMPREPLY=(); case "$3" in -h | --help) return 0 ;; -k | --keep) COMPREPLY=($( compgen -W '1 2 3 4 5 6 7 8 9' -- "$2" )); return 0 ;; esac; if [[ "$2" == -* ]]; then COMPREPLY=($( compgen -W '--old --new --space --keep --nocheck --help' -- "$2" )); return 0; fi; COMPREPLY=($( compgen -d -- "$2" )) } _yu_repoquery () { COMPREPLY=(); local groupmode=false; for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ )) do case "${COMP_WORDS[i]}" in -g | --group) groupmode=true; break ;; esac; done; case "$3" in -h | --help | --version | -f | --file | --qf | --queryformat | --resolve | --archlist | --whatprovides | --whatrequires | --whatobsoletes | --whatconflicts | --repofrompath) return 0 ;; -l | --list | -i | --info | -R | --requires) if $groupmode; then _yum_grouplist "" "$2" 2> /dev/null; else _yum_list all "$2" 2> /dev/null; fi; return 0 ;; --provides | --obsoletes | --conflicts | --groupmember | --changelog | --location | --nevra | --envra | --nvr | -s | --source) _yum_list all "$2" 2> /dev/null; return 0 ;; --grouppkgs) COMPREPLY=($( compgen -W 'all default optional mandatory' -- "$2" )); return 0 ;; --pkgnarrow) COMPREPLY=($( compgen -W 'all available updates installed extras obsoletes recent repos' -- "$2" )); return 0 ;; --repoid) _yum_repolist all "$2" 2> /dev/null; return 0 ;; --enablerepo) _yum_repolist disabled "$2" 2> /dev/null; return 0 ;; --disablerepo) _yum_repolist enabled "$2" 2> /dev/null; return 0 ;; -c) COMPREPLY=($( compgen -f -o plusdirs -X '!*.conf' -- "$2" )); return 0 ;; esac; COMPREPLY=($( compgen -W '--version --help --list --info --file --queryformat --groupmember --all --requires --provides --obsoletes --conflicts --changelog --location --nevra --envra --nvr --source --srpm --resolve --exactdeps --recursive --whatprovides --whatrequires --whatobsoletes --whatconflicts --group --grouppkgs --archlist --pkgnarrow --installed --show-duplicates --repoid --enablerepo --disablerepo --repofrompath --plugins --quiet --verbose --cache --tempcache --querytags --config --tree-requires --tree-conflicts --tree-obsoletes --tree-whatrequires' -- "$2" )) } _yu_verifytree () { COMPREPLY=(); case "$3" in -h | --help | -t | --testopia) return 0 ;; esac; if [[ "$2" == -* ]]; then COMPREPLY=($( compgen -W '--help --checkall --testopia --treeinfo' -- "$2" )); return 0; fi; COMPREPLY=($( compgen -d -- "$2" )) } _yu_yumdb () { COMPREPLY=(); case "$3" in -h | --help | -version) return 0 ;; -c | --config) COMPREPLY=($( compgen -f -o plusdirs -X '!*.conf' -- "$2" )); return 0 ;; shell) COMPREPLY=($( compgen -f -o plusdirs -- "$2" )); return 0 ;; esac; if [ $COMP_CWORD -le 1 ]; then COMPREPLY=($( compgen -W 'get set del rename rename-force copy search exist unset info shell --version --help --noplugins --config' -- "$2" )); fi } _yum () { COMPREPLY=(); local yum=$1; local cur prev; local -a words; if type _get_comp_words_by_ref &>/dev/null; then _get_comp_words_by_ref cur prev words; else cur=$2 prev=$3 words=("${COMP_WORDS[@]}"); fi; local cmds=(check check-update clean deplist distro-sync downgrade groupinfo groupinstall grouplist groupremove help history info install list makecache provides reinstall remove repolist resolvedep search shell update upgrade version); local i c cmd subcmd; for ((i=1; i < ${#words[@]}-1; i++ )) do [[ -n $cmd ]] && subcmd=${words[i]} && break; for c in ${cmds[@]} check-rpmdb distribution-synchronization erase groupupdate grouperase localinstall localupdate whatprovides; do [[ ${words[i]} == $c ]] && cmd=$c && break; done; done; case $cmd in check | check-rpmdb) COMPREPLY=($( compgen -W 'dependencies duplicates all' -- "$cur" )); return 0 ;; check-update | grouplist | makecache | provides | whatprovides | resolvedep | search) return 0 ;; clean) if [ "$prev" = clean ]; then COMPREPLY=($( compgen -W 'expire-cache packages headers metadata cache dbcache all' -- "$cur" )); fi; return 0 ;; deplist) COMPREPLY=($( compgen -f -o plusdirs -X '!*.[rs]pm' -- "$cur" )); [[ "$cur" == */* ]] || _yum_list all "$cur"; return 0 ;; downgrade | reinstall) _yum_binrpmfiles "$cur"; [[ "$cur" == */* ]] || _yum_list installed "$cur"; return 0 ;; erase | remove | distro-sync | distribution-synchronization) _yum_list installed "$cur"; return 0 ;; group*) _yum_grouplist "" "$cur"; return 0 ;; help) if [ "$prev" = help ]; then COMPREPLY=($( compgen -W '${cmds[@]}' -- "$cur" )); fi; return 0 ;; history) case $prev in history) COMPREPLY=($( compgen -W 'info list summary undo redo new addon-info package-list' -- "$cur" )) ;; undo | redo | repeat | addon | addon-info) COMPREPLY=($( compgen -W "last $( $yum -d 0 -C history 2>/dev/null | sed -ne 's/^[[:space:]]*\([0-9]\{1,\}\).*/\1/p' )" -- "$cur" )) ;; esac; case $subcmd in package-list | pkg | pkgs | pkg-list | pkgs-list | package | packages | packages-list) _yum_list installed "$cur" ;; esac; return 0 ;; info) _yum_list all "$cur"; return 0 ;; install) _yum_binrpmfiles "$cur"; [[ "$cur" == */* ]] || _yum_list available "$cur"; return 0 ;; list) if [ "$prev" = list ]; then COMPREPLY=($( compgen -W 'all available updates installed extras obsoletes recent' -- "$cur" )); fi; return 0 ;; localinstall | localupdate) _yum_binrpmfiles "$cur"; return 0 ;; repolist) if [ "$prev" = repolist ]; then COMPREPLY=($( compgen -W 'all enabled disabled' -- "$cur" )); fi; return 0 ;; shell) if [ "$prev" = shell ]; then COMPREPLY=($( compgen -f -o plusdirs -- "$cur" )); fi; return 0 ;; update | upgrade) _yum_binrpmfiles "$cur"; [[ "$cur" == */* ]] || _yum_list updates "$cur"; return 0 ;; version) if [ "$prev" = version ]; then COMPREPLY=($( compgen -W 'all installed available nogroups grouplist groupinfo' -- "$cur" )); fi; return 0 ;; esac; _yum_complete_baseopts "$cur" "$prev" && return 0; COMPREPLY=($( compgen -W '$( _yum_baseopts ) ${cmds[@]}' -- "$cur" )) } _yum_baseopts () { local opts='--help --tolerant --cacheonly --config --randomwait --debuglevel --showduplicates --errorlevel --rpmverbosity --quiet --verbose --assumeyes --version --installroot --enablerepo --disablerepo --exclude --disableexcludes --obsoletes --noplugins --nogpgcheck --skip-broken --color --releasever --setopt'; [[ $COMP_LINE == *--noplugins* ]] || opts="$opts --disableplugin --enableplugin"; printf %s "$opts" } _yum_binrpmfiles () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -f -o plusdirs -X '!*.rpm' -- "$1" )); COMPREPLY=($( compgen -W '"${COMPREPLY[@]}"' -X '*.src.rpm' )); COMPREPLY=($( compgen -W '"${COMPREPLY[@]}"' -X '*.nosrc.rpm' )) } _yum_complete_baseopts () { local split=false; type _split_longopt &>/dev/null && _split_longopt && split=true; case $2 in -d | --debuglevel | -e | --errorlevel) COMPREPLY=($( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- "$1" )); return 0 ;; --rpmverbosity) COMPREPLY=($( compgen -W 'info critical emergency error warn debug' -- "$1" )); return 0 ;; -c | --config) COMPREPLY=($( compgen -f -o plusdirs -X "!*.conf" -- "$1" )); return 0 ;; --installroot | --downloaddir) COMPREPLY=($( compgen -d -- "$1" )); return 0 ;; --enablerepo) _yum_repolist disabled "$1"; return 0 ;; --disablerepo) _yum_repolist enabled "$1"; return 0 ;; --disableexcludes) _yum_repolist all "$1"; COMPREPLY=($( compgen -W '${COMPREPLY[@]} all main' -- "$1" )); return 0 ;; --enableplugin) _yum_plugins 0 "$1"; return 0 ;; --disableplugin) _yum_plugins 1 "$1"; return 0 ;; --color) COMPREPLY=($( compgen -W 'always auto never' -- "$1" )); return 0 ;; -R | --randomwait | -x | --exclude | -h | --help | --version | --releasever | --cve | --bz | --advisory | --tmprepo | --verify-filenames | --setopt) return 0 ;; --download-order) COMPREPLY=($( compgen -W 'default smallestfirst largestfirst' -- "$1" )); return 0 ;; --override-protection) _yum_list installed "$1"; return 0 ;; --verify-configuration-files) COMPREPLY=($( compgen -W '1 0' -- "$1" )); return 0 ;; esac; $split && return 0 || return 1 } _yum_grouplist () { local IFS=' '; COMPREPLY=($( compgen -W "$( ${yum:-yum} -C grouplist $1 "$2*" 2>/dev/null | sed -ne 's/^[[:space:]]\{1,\}\(.\{1,\}\)/\1/p' )" -- "$2" )) } _yum_list () { if [ "$1" = all ]; then COMPREPLY=("${COMPREPLY[@]}" $( ${yum:-yum} -d 0 -C list $1 "$2*" 2>/dev/null | sed -ne '/^Available /d' -e '/^Installed /d' -e '/^Updated /d' -e 's/[[:space:]].*//p' )); else COMPREPLY=("${COMPREPLY[@]}" $( ${yum:-yum} -d 0 -C list $1 "$2*" 2>/dev/null | sed -ne 1d -e 's/[[:space:]].*//p' )); fi } _yum_plugins () { local val; [ $1 = 1 ] && val='\(1\|yes\|true\|on\)' || val='\(0\|no\|false\|off\)'; COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '$( command grep -il "^\s*enabled\s*=\s*$val" \ /etc/yum/pluginconf.d/*.conf 2>/dev/null \ | sed -ne "s|^.*/\([^/]\{1,\}\)\.conf$|\1|p" )' -- "$2" )) } _yum_repolist () { COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( ${yum:-yum} --noplugins -C repolist $1 2>/dev/null | sed -ne '/^repo\s\{1,\}id/d' -e '/^repolist:/d' -e 's/[[:space:]].*//p' )" -- "$2" )) } command_not_found_handle () { runcnf=1; retval=127; [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0; [ ! -x /usr/libexec/packagekitd ] && runcnf=0; if [ $runcnf -eq 1 ]; then /usr/libexec/pk-command-not-found $@; retval=$?; else echo "bash: $1: command not found"; fi; return $retval } dequote () { eval echo "$1" 2> /dev/null } quote () { echo \'${1//\'/\'\\\'\'}\' } quote_readline () { local quoted; _quote_readline_by_ref "$1" ret; printf %s "$ret" }