Created
July 1, 2013 17:00
-
-
Save kennyp/5902608 to your computer and use it in GitHub Desktop.
Auto-complete for hcl.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_hcl () { | |
local cur prev opts cmds tasks | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="--help --version" | |
cmds="show tasks aliases set unset start stop resume note" | |
if [[ ${cur} == -* ]] ; then | |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) | |
return 0 | |
elif [[ ${prev} == hcl ]] ; then | |
COMPREPLY=($(compgen -W "${cmds}" -- ${cur})) | |
return 0 | |
elif [[ ${prev} == start ]] ; then | |
tasks=$(cat ~/.hcl_settings | grep ^task. | cut -d. -f2 | cut -d: -f1 | tr '\n' ' ') | |
COMPREPLY=($(compgen -W "${tasks}" -- ${cur})) | |
return 0 | |
fi | |
} | |
complete -F _hcl hcl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment