Skip to content

Instantly share code, notes, and snippets.

@haron
Created April 14, 2011 20:27
Show Gist options
  • Save haron/920433 to your computer and use it in GitHub Desktop.
Save haron/920433 to your computer and use it in GitHub Desktop.
dsh bash completion file
# dsh(1) completion
_dsh() {
local cur prev machines groups
COMPREPLY=()
_get_comp_words_by_ref cur prev
[ -d ~/.dsh ] || return 0
group=""
machines="$(find -L ~/.dsh -type f -exec cat {} \;)"
[ -d ~/.dsh/group ] && group="$(ls ~/.dsh/group)"
case $prev in
-m|--machine)
COMPREPLY=( $( compgen -W "$machines" -- "$cur" ) )
;;
-g|--group)
COMPREPLY=( $( compgen -W "$group" -- "$cur" ) )
;;
esac
return 0
}
complete -F _dsh dsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment