Created
October 24, 2017 08:30
-
-
Save Gnappuraz/40046db4adea05587bc218044f288b13 to your computer and use it in GitHub Desktop.
Autocompletion for Snakebite on Mac
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
| _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