Skip to content

Instantly share code, notes, and snippets.

@meagar
Last active October 28, 2024 20:26
Show Gist options
  • Save meagar/1f98487788baac1e4085ae88baa4187b to your computer and use it in GitHub Desktop.
Save meagar/1f98487788baac1e4085ae88baa4187b to your computer and use it in GitHub Desktop.
Tab completion for Thor and Rake in bash, handling colons
# ~/.bash_profile
_thorcomplete() {
local cur
_get_comp_words_by_ref -n : cur
COMPREPLY=($(compgen -W "`bundle exec thor list | grep 'thor ' | cut -d " " -f 2`" -- $cur))
__ltrim_colon_completions "$cur"
}
complete -o default -o nospace -F _thorcomplete thor
# For rake:
_rakecomplete() {
local cur
_get_comp_words_by_ref -n : cur
COMPREPLY=($(compgen -W "`bundle exec rake -T | cut -d " " -f 2`" -- $cur))
__ltrim_colon_completions "$cur"
}
complete -o default -o nospace -F _rakecomplete rake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment