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
| # docker bash command with autocompletion
# put this into ~/.bashrc
# standard docker completion provided by docker-ce-cli
# enable debugging with this variable:
#export BASH_COMP_DEBUG_FILE=/dev/stdout
source /usr/share/bash-completion/completions/docker
function dbash() {
docker exec -it "$1" bash;
}
function dbashwww() {
docker exec -it "$1" su -s/bin/bash www-data;
}
function dtail() {
docker logs -f "$@";
}
_dbash() {
#__start_docker loads variables itself and can't be used
local cur prev words cword split
cur="$2"
words=(docker stop "$2")
cword=2
local out directive
__docker_get_completion_results
__docker_process_completion_results
}
complete -F _dbash dbash
complete -F _dbash dbashwww
complete -F _dbash dtail
|