Skip to content

Commit

Permalink
Include autocomplete with pyromania.
Browse files Browse the repository at this point in the history
  • Loading branch information
FlipperPA committed Mar 31, 2023
1 parent 29a3b4a commit 3235f9e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pyro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,26 @@ function fn_pyro() {
fi
}
alias pyro=fn_pyro

pyro_autocomplete()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

if [ $COMP_CWORD -eq 1 ]; then
# First argument can be a venv name or help
opts=`pyro --autocomplete-list`
opts="--help -h ${opts}"
elif [ $COMP_CWORD -eq 2 ]; then
# Second argument can only be an action
opts="--create -c --delete -d --packages -p"
fi

if [[ ${cur} == * ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F pyro_autocomplete pyro

0 comments on commit 3235f9e

Please sign in to comment.