Skip to content

Instantly share code, notes, and snippets.

@caseyfw
Last active March 15, 2018 23:43
Show Gist options
  • Save caseyfw/51bdbcb37e5dfb91b74e to your computer and use it in GitHub Desktop.
Save caseyfw/51bdbcb37e5dfb91b74e to your computer and use it in GitHub Desktop.
Bash auto completion for Robo taskrunner (with options and caching)
#!/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//:}
@amenk
Copy link

amenk commented Aug 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment