-
-
Save caseyfw/51bdbcb37e5dfb91b74e to your computer and use it in GitHub Desktop.
Bash auto completion for Robo taskrunner (with options and caching)
This file contains hidden or 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
#!/bin/sh | |
function __robo_list_cmds () | |
{ | |
if [ ! -e /tmp/robo_commands ]; then | |
robo list --raw | awk '{print $1}' | sort > /tmp/robo_commands | |
fi | |
cat /tmp/robo_commands | |
} | |
function __robo_list_opts () | |
{ | |
if [ ! -e /tmp/robo_options ]; then | |
robo list --no-ansi | sed -e '1,/Options:/d' -e '/^$/,$d' -e 's/^ *//' -e 's/ .*//' | sort > /tmp/robo_options | |
fi | |
cat /tmp/robo_options | |
} | |
_robo() | |
{ | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
COMPREPLY=($(compgen -W "$(__robo_list_opts) $(__robo_list_cmds)" -- ${cur})) | |
return 0; | |
} | |
complete -o default -F _robo robo | |
COMP_WORDBREAKS=${COMP_WORDBREAKS//:} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Improved version: https://gist.github.com/amenk/d68f1fe54b156952ced621f771ff48ba