-
-
Save haron/920433 to your computer and use it in GitHub Desktop.
dsh bash completion file
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
# 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