Lately I've been playing alot with the PEAR CLI. The one annoying thing I noticed the most was its lack of tab completion that I'm used to from the shell. It turns out that this feature is very easy to add, in the bash at least.
Here (Update: Now it's in
PEAR SVN repository) is a simple tab completion script for the bash. In addition to completing the PEAR commands and their respective options, it can even autocomplete the names of installed packages and discovered PEAR channels. Just source it, and enjoy
Hope to see it included in PEAR one day.
_pear()
{
local cur
COMREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
package)
_filedir '@(xml)'
;;
)
case "$cur" in
-*)
COMREPLY=( $( compgen -W '-c -C -d -D -G -h -q -s -S -u \
-v -V' -- $cur ) )
;;
)
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W "help `pear 2>&1 | \
awk '{ORS=" "} /[a-zA-Z-]+ / {print $1}'`" -- $cur ) )
else
_filedir
fi
;;
esac
esac
return 0
}
Confusion, where do I insert this code?
Anyway, this seems interesting. Thanks!
JP
You need to put the file somewhere, and then source it each time bash starts. You can add a line like these to your ~/.bashrc:
source /path/to/this/file