Skip to content

Instantly share code, notes, and snippets.

@tmichel
Created October 11, 2022 18:40
Show Gist options
  • Save tmichel/20e6fd9f13c082e227b8b6f39feb450b to your computer and use it in GitHub Desktop.
Save tmichel/20e6fd9f13c082e227b8b6f39feb450b to your computer and use it in GitHub Desktop.
fish shell completion for databricks-cli
# 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