Skip to content

Instantly share code, notes, and snippets.

@Gnappuraz
Created October 24, 2017 08:30
Show Gist options
  • Select an option

  • Save Gnappuraz/40046db4adea05587bc218044f288b13 to your computer and use it in GitHub Desktop.

Select an option

Save Gnappuraz/40046db4adea05587bc218044f288b13 to your computer and use it in GitHub Desktop.
Autocompletion for Snakebite on Mac
_snakebite()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ${prev} != "snakebite" ]]; then
local IFS=$'\t\n'
if [[ $cur != /* ]] ; then
cur="/user/$(whoami)/$cur"
fi
last_root=$(echo $cur | grep -o "^/\([^/]*/\)*")
opts=$(snakebite complete $last_root)
if [[ ${cur} == * ]]; then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
else
opts=$(snakebite commands)
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
}
complete -o nospace -F _snakebite snakebite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment