diff options
Diffstat (limited to 'completions/_mount')
-rw-r--r-- | completions/_mount | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/completions/_mount b/completions/_mount index 85f5490..ab385f1 100644 --- a/completions/_mount +++ b/completions/_mount @@ -14,16 +14,16 @@ fi # query the server for a list of all available exports and complete on # that instead. # -_mount() +_comp_cmd_mount() { - local cur prev words cword - _init_completion -n : || return + local cur prev words cword comp_args + _comp_initialize -n : -- "$@" || return local sm host case $prev in -t | --types) - _fstypes + _comp_compgen_fstypes return ;; esac @@ -33,8 +33,9 @@ _mount() 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#*:}")) + _comp_compgen -c "${cur#*:}" split -- "$( + "$sm" -e ${cur%%:*} | _comp_awk 'NR>1 {print $1}' + )" return done fi @@ -42,24 +43,30 @@ _mount() if [[ $cur == //* ]]; then host=${cur#//} host=${host%%/*} - if [[ -n $host ]]; then - COMPREPLY=($(compgen -P "//$host" -W \ - "$(smbclient -d 0 -NL $host 2>/dev/null | + if [[ $host ]]; then + _comp_compgen -c "${cur#//"$host"}" split -P "//$host" -- "$( + smbclient -d 0 -NL "$host" 2>/dev/null | command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | - command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \ - -- "${cur#//$host}")) + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p' + )" fi elif [[ -r /etc/vfstab ]]; then # Solaris - COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab)" -- "$cur")) + _comp_compgen_split -- "$( + _comp_awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab + )" elif [[ ! -e /etc/fstab ]]; then # probably Cygwin - COMPREPLY=($(compgen -W "$($1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}')" -- "$cur")) + _comp_compgen_split -- "$( + "$1" | _comp_awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' + )" else # probably BSD - COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab)" -- "$cur")) + _comp_compgen_split -- "$( + _comp_awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab + )" fi } && - complete -F _mount -o default -o dirnames mount + complete -F _comp_cmd_mount -o default -o dirnames mount # ex: filetype=sh |