Skip to content

Instantly share code, notes, and snippets.

@HansRobo
Last active March 10, 2020 04:35
Show Gist options
  • Save HansRobo/38060a841ca6be71181ccc9dcc62c86e to your computer and use it in GitHub Desktop.
Save HansRobo/38060a841ca6be71181ccc9dcc62c86e to your computer and use it in GitHub Desktop.
#!bash
_chdistro() {
local cur prev cword opts
_get_comp_words_by_ref -n : cur prev cword
case "$3" in
chdistro)
COMPREPLY=( $(compgen -W "$(ls /opt/ros/)" -- "${cur}") );;
*)
COMPREPLY=( $(compgen -W "$(ls -F $HOME | grep /| sed -E "s@^@~/@g")" -- "${cur}") );;
esac
}
complete -o nospace -F _chdistro chdistro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment