Skip to content

Commit

Permalink
Add bash completion for exercism opts
Browse files Browse the repository at this point in the history
  • Loading branch information
nywilken committed Nov 4, 2018
1 parent e98310f commit 517f301
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions shell/exercism_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@ _exercism () {
COMPREPLY=() # Array variable storing the possible completions.
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
opts="--verbose --timeout"

commands="configure download open
submit troubleshoot upgrade version workspace help"
config_opts="--show"
version_opts="--latest"

if [ "${#COMP_WORDS[@]}" -eq 2 ]; then
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
return 0
case "${cur}" in
-*)
COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
return 0
;;
*)
COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) )
return 0
;;
esac
fi

if [ "${#COMP_WORDS[@]}" -eq 3 ]; then
Expand Down

0 comments on commit 517f301

Please sign in to comment.