This commit is contained in:
Freddy Vulto 2009-10-18 12:38:04 +02:00
parent ffe704c24b
commit 0dda212d95

View File

@ -402,22 +402,23 @@ _filedir()
while read -r tmp; do while read -r tmp; do
echo $tmp echo $tmp
done done
} }
)) ))
if [[ "$1" != -d ]]; then if [[ "$1" != -d ]]; then
xspec=${1:+"!*.$1"} xspec=${1:+"!*.$1"}
toks=( ${toks[@]-} $( toks=( ${toks[@]-} $(
compgen -f -X "$xspec" -- "$(quote_readline "$cur")" | { compgen -f -X "$xspec" -- "$(quote_readline "$cur")" | {
while read -r tmp; do while read -r tmp; do
[ -n $tmp ] && echo $tmp [ -n $tmp ] && echo $tmp
done done
} }
)) ))
fi fi
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" ) COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
} } # _filedir()
# This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it # This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it
# easier to support both "--foo bar" and "--foo=bar" style completions. # easier to support both "--foo bar" and "--foo=bar" style completions.
@ -691,7 +692,7 @@ _realcommand() {
else else
type -P "$1" type -P "$1"
fi fi
} }
} }
@ -735,8 +736,8 @@ deinstall clean clean-depends kernel buildworld' make
# that script's available commands # that script's available commands
# #
{ have service || [ -d /etc/init.d/ ]; } && { have service || [ -d /etc/init.d/ ]; } &&
_service() _service()
{ {
local cur prev sysvdir local cur prev sysvdir
COMPREPLY=() COMPREPLY=()
@ -762,15 +763,16 @@ deinstall clean clean-depends kernel buildworld' make
fi fi
return 0 return 0
} && } &&
complete -F _service service complete -F _service service
[ -d /etc/init.d/ ] && complete -F _service $default \ [ -d /etc/init.d/ ] && complete -F _service $default \
$(for i in /etc/init.d/*; do echo ${i##*/}; done) $(for i in /etc/init.d/*; do echo ${i##*/}; done)
# chown(1) completion
# # chown(1) completion
_chown() #
{ _chown()
{
local cur prev split=false local cur prev split=false
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
@ -807,13 +809,14 @@ deinstall clean clean-depends kernel buildworld' make
;; ;;
esac esac
fi fi
} } # _chown()
complete -F _chown $filenames chown complete -F _chown $filenames chown
# chgrp(1) completion
# # chgrp(1) completion
_chgrp() #
{ _chgrp()
{
local cur prev split=false local cur prev split=false
COMPREPLY=() COMPREPLY=()
@ -848,14 +851,15 @@ deinstall clean clean-depends kernel buildworld' make
fi fi
return 0 return 0
} } # _chgrp()
complete -F _chgrp $filenames chgrp complete -F _chgrp $filenames chgrp
# umount(8) completion. This relies on the mount point being the third
# space-delimited field in the output of mount(8) # umount(8) completion. This relies on the mount point being the third
# # space-delimited field in the output of mount(8)
_umount() #
{ _umount()
{
local cur IFS=$'\n' local cur IFS=$'\n'
COMPREPLY=() COMPREPLY=()
@ -864,17 +868,18 @@ deinstall clean clean-depends kernel buildworld' make
COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) )
return 0 return 0
} }
complete -F _umount $dirnames umount complete -F _umount $dirnames umount
# mount(8) completion. This will pull a list of possible mounts out of
# /etc/{,v}fstab, unless the word being completed contains a ':', which # mount(8) completion. This will pull a list of possible mounts out of
# would indicate the specification of an NFS server. In that case, we # /etc/{,v}fstab, unless the word being completed contains a ':', which
# query the server for a list of all available exports and complete on # would indicate the specification of an NFS server. In that case, we
# that instead. # query the server for a list of all available exports and complete on
# # that instead.
_mount() #
{ _mount()
{
local cur i sm host prev local cur i sm host prev
COMPREPLY=() COMPREPLY=()
@ -913,15 +918,16 @@ deinstall clean clean-depends kernel buildworld' make
fi fi
return 0 return 0
} } # _mount()
complete -F _mount $default $dirnames mount complete -F _mount $default $dirnames mount
# Linux rmmod(8) completion. This completes on a list of all currently
# installed kernel modules. # Linux rmmod(8) completion. This completes on a list of all currently
# # installed kernel modules.
have rmmod && { #
_rmmod() have rmmod && {
{ _rmmod()
{
local cur local cur
COMPREPLY=() COMPREPLY=()
@ -929,15 +935,16 @@ deinstall clean clean-depends kernel buildworld' make
_installed_modules "$cur" _installed_modules "$cur"
return 0 return 0
} } # _rmmod()
complete -F _rmmod rmmod complete -F _rmmod rmmod
# Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
# list of all available modules for the version of the kernel currently # Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
# running. # list of all available modules for the version of the kernel currently
# # running.
_insmod() #
{ _insmod()
{
local cur prev modpath local cur prev modpath
COMPREPLY=() COMPREPLY=()
@ -968,9 +975,10 @@ deinstall clean clean-depends kernel buildworld' make
fi fi
return 0 return 0
} } # _insmod
complete -F _insmod $filenames insmod modprobe modinfo complete -F _insmod $filenames insmod modprobe modinfo
} } # have rmmod
# renice(8) completion # renice(8) completion
# #
@ -1002,6 +1010,7 @@ _renice()
} }
complete -F _renice renice complete -F _renice renice
# kill(1) completion # kill(1) completion
# #
_kill() _kill()
@ -1156,7 +1165,7 @@ _known_hosts()
[ "$1" = -a ] || [ "$2" = -a ] && options=-a [ "$1" = -a ] || [ "$2" = -a ] && options=-a
[ "$1" = -c ] || [ "$2" = -c ] && options="$options -c" [ "$1" = -c ] || [ "$2" = -c ] && options="$options -c"
_known_hosts_real $options "$(_get_cword)" _known_hosts_real $options "$(_get_cword)"
} } # _known_hosts()
# Helper function for completing _known_hosts. # Helper function for completing _known_hosts.
# This function performs host completion based on ssh's known_hosts files. # This function performs host completion based on ssh's known_hosts files.
@ -1324,7 +1333,7 @@ _known_hosts_real()
fi fi
return 0 return 0
} } # _known_hosts_real()
complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \ complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr