pyg
pyg copied to clipboard
Shell TAB autocompletion
argh should provide it.
argh's creator a while ago (Pyg 0.5 !) suggested me to add this in my ~/.bashrc
:
# argh-powered python scripts
_argh_completion()
{
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
ARGH_AUTO_COMPLETE=1 $1 ) )
}
complete -o default -F _argh_completion pyg
But, unfortunately, it does not work. If you type TAB Pyg shows the usage and that's annoying...
This works... But I don't know if it is correct.
Create the file /etc/bash_completion.d/pyg
:
_pyg()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="install bundle download pack remove search list site update check link unlink shell help"
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
}
complete -o default -F _pyg pyg
then source /etc/bash_completion.d/pyg
and then bash completion should be ok for the subcommands...
I think for now it is enogh. We can extend it in next releases.
Heh, and for zsh users ? ;)
:D Sorry I don't know how to do that for zsh... Do you have any idea? :)