-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_completion1.sh
39 lines (27 loc) · 1016 Bytes
/
bash_completion1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/bash
if ! command -v workspace &> /dev/null; then
return
fi
__autocomplection_workspace() {
if [ -z "$WORKSPACE_PATH" ]; then
WORKSPACE_PATH="$HOME/Work"
fi
command_named=$1
current_word_called=$2
word_before_called=$3
if [ "${#COMP_WORDS[@]}" = "2" ]; then
COMPREPLY=($(compgen -W "init i cd go path help --help -h" "${current_word_called}"))
elif [ "${#COMP_WORDS[@]}" = "3" ]; then
case $word_before_called in
cd | go | path ) COMPREPLY=($(compgen -W "`ls $WORKSPACE_PATH 2> /dev/null`" "${current_word_called}")) ;;
help ) COMPREPLY=($(compgen -W "init i cd go" "${current_word_called}")) ;;
esac
elif [ "${#COMP_WORDS[@]}" = "4" ]; then
case "${COMP_WORDS[1]}" in
cd | go ) COMPREPLY=($(compgen -W "`ls "$WORKSPACE_PATH/$word_before_called" 2> /dev/null`" "${current_word_called}")) ;;
esac
fi
return 0
}
complete -o default -F __autocomplection_workspace workspace
complete -o default -F __autocomplection_workspace wrk