[BACK]Return to mtctl-completion.bash CVS log [TXT][DIR] Up to [local] / mtctl

File: [local] / mtctl / mtctl-completion.bash (download)

Revision 1.3, Sun May 29 14:30:49 2022 UTC (6 months, 1 week ago) by miniontoby
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -2 lines

Speed Update!

_mtctl_completions() {
        case $COMP_CWORD in
                1) local suggestions=($(compgen -W "start stop restart status create backup list version help" -- "${COMP_WORDS[1]}"))
                ;;
                2) if [ "${COMP_WORDS[1]}" == "help" ] || [ "${COMP_WORDS[1]}" == "list" ] || [ "${COMP_WORDS[1]}" == "version" ]; then return; fi
local suggestions=($(cd $(cat $HOME/.mtctl/config | grep 'location' | sed -e 's/location\=//')/worlds && compgen -d "${COMP_WORDS[2]}"))
                ;;
		*) return
		;;
        esac
        if [ "${#suggestions[@]}" == "1" ]; then
                local number=$(echo ${suggestions[0]/%\ */})
                COMPREPLY=("$number")
        else
                COMPREPLY=("${suggestions[@]}")
        fi
}

complete -F _mtctl_completions mtctl