[Gllug] apt-get tab complete
Stig Brautaset
stigbrau at online.no
Mon Oct 15 18:59:26 UTC 2001
Hi there,
An acquaintance of mine has written an apt-get tab-completion thingy for
bash (2?). If you put this snippet somewhere in your .bashrc (or put
this in a separate file and source if from .bashrc) you can use tab to
complete not only the first part, but also the install / update /
dist-upgrade part, and even the package names part.
Not much use maybe, but a cool hack.
# file starts here
function __apt_complete()
{
local c=${COMP_WORDS[$COMP_CWORD]}
if [ $COMP_CWORD == 1 ]
then
COMPREPLY=(`echo -e 'install\nremove\nupdate\ndist-upgrade' | grep '^'$c`)
else
if [ ${COMP_WORDS[1]} == "install" -o ${COMP_WORDS[1]} == "remove" ]
then
COMPREPLY=(`apt-cache pkgnames | grep '^'$c`)
fi
fi
}
complete -F __apt_complete apt-get
function __modprobe_complete()
{
local c=${COMP_WORDS[$COMP_CWORD]}
COMPREPLY=(`sed '/^$/D;/.o:$/!D;s/.*\///g;s/\.o:$//g' /lib/modules/$(uname -r)/modules.dep | grep '^'$c`)
}
complete -F __modprobe_complete modprobe insmod rmmod
# file ends here
Regards,
Stig
--
brautaset.org
Registered Linux User 107343
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list