pyg icon indicating copy to clipboard operation
pyg copied to clipboard

Shell TAB autocompletion

Open rubik opened this issue 12 years ago • 5 comments

argh should provide it.

rubik avatar Jul 14 '11 16:07 rubik

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...

rubik avatar Jul 18 '11 07:07 rubik

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...

rubik avatar Jul 27 '11 15:07 rubik

I think for now it is enogh. We can extend it in next releases.

rubik avatar Aug 03 '11 09:08 rubik

Heh, and for zsh users ? ;)

fdev31 avatar Aug 03 '11 12:08 fdev31

:D Sorry I don't know how to do that for zsh... Do you have any idea? :)

rubik avatar Aug 03 '11 18:08 rubik