Created
October 11, 2022 18:40
-
-
Save tmichel/20e6fd9f13c082e227b8b6f39feb450b to your computer and use it in GitHub Desktop.
fish shell completion for databricks-cli
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
# Put this in ~/.config/fish/completions | |
function __fish_complete_databricks | |
set -l cl (commandline -pc) | |
set -l help_command (echo $cl | sed 's/[[:alnum:]-]*$/--help/') | |
if string match -r -- '--?\w*' $cl | |
# complete options | |
eval $help_command \ | |
| sed -e '1,/Options:/ d' -e '/Commands:/,$ d' \ | |
| grep -Eo -- '--?[[:alpha:]]+' | |
else | |
# complete commands | |
eval $help_command \ | |
| sed '1,/Commands:/ d' \ | |
| grep '^ [[:alpha:]]' \ | |
| awk '{print $1}' | |
end | |
end | |
complete -c databricks -a "(__fish_complete_databricks)" -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment