- add netstat to list of commands that complete on long options

- add renice completion, submitted by Michael G <michaelg@amerion.net>,
  and rewritten helper functions _pids() and _pgids()
This commit is contained in:
ianmacd 2002-04-02 06:17:35 +00:00
parent a0514e1d73
commit f91a652220

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05a
#
# $Id: bash_completion,v 1.243 2002/04/02 07:27:50 ianmacd Exp $
# $Id: bash_completion,v 1.244 2002/04/02 08:17:35 ianmacd Exp $
#
# Copyright (C) Ian Macdonald <ian@caliban.org>
#
@ -167,6 +167,20 @@ _expand()
fi
}
# This function completes on process IDs
#
_pids()
{
COMPREPLY=( $( compgen -W '$( ps axo pid | sed 1d )' -- $cur ) )
}
# This function completes on process group IDs
#
_pgids()
{
COMPREPLY=( $( compgen -W '$( ps axo pgid | sed 1d )' -- $cur ) )
}
# start of section containing completion functions for bash built-ins
# bash alias completion
@ -449,6 +463,36 @@ _man()
}
[ $OS = Linux -o $OS = Darwin ] && complete -F _man -o filenames man
# renice(8) completion
#
_renice()
{
local command cur curopt i
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
command=$1
i=0
# walk back throuh command line and find last option
while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
curopt=${COMP_WORDS[COMP_CWORD-$i]}
case "$curopt" in
-u)
COMPREPLY=( $( compgen -u -- $cur ) )
;;
-g)
_pgids
;;
-p|$command)
_pids
;;
esac
i=$(( ++i ))
done
}
complete -F _renice renice
# kill(1) completion
#
_kill()
@ -2063,7 +2107,7 @@ for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
touch vdir xargs awk gperf grep gpg grub indent less m4 sed shar date \
env seq su tee uname who texindex cat csplit cut expand fmt fold head \
md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
uniq wc units wget rsync ldd bash id info irb mkdir rmdir; do
uniq wc units wget rsync ldd bash id info irb mkdir rmdir netstat; do
have $i && complete -F _longopt -o filenames $i
done
unset i