forked from byjg/usdocker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_completion_debian.sh
More file actions
executable file
·39 lines (28 loc) · 1.08 KB
/
Copy pathbash_completion_debian.sh
File metadata and controls
executable file
·39 lines (28 loc) · 1.08 KB
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/env bash
_usdocker()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
service="${COMP_WORDS[1]}"
command="${COMP_WORDS[2]}"
if [ "$prev" == "usdocker" ]; then
_script_commands="$(usdocker .autocomplete get) env"
elif [ "$cur" != "env" ] && [ "$prev" != "env" ] && [ "$COMP_CWORD" == "2" ]; then
_script_commands="`usdocker .autocomplete get $prev` env"
elif [ "$prev" == "setup" ]; then
_script_commands="--reset --reset-env --reset-data --set"
elif [ "$prev" == "--set" ]; then
_script_commands="$(usdocker .autocomplete __set $service)"
elif [ "$service" == "docker-compose" ] && [ "$prev" == "up" ]; then
_script_commands="`ls ~/.docker/machine/machines/` local"
elif [ "$service" == "docker-compose" ] && [ "$command" == "up" ] && [ "$COMP_CWORD" == 4 ]; then
_script_commands="`ls docker-compose-* | cut -d- -f3 | cut -d. -f1`"
else
_script_commands=""
fi
COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) )
return 0
}
complete -F _usdocker usdocker