-
Notifications
You must be signed in to change notification settings - Fork 36
/
docker-aliases.plugin.zsh
57 lines (47 loc) · 1.02 KB
/
docker-aliases.plugin.zsh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Defines Docker aliases.
#
# Author:
# François Vantomme <[email protected]>
#
# Return if requirements are not found.
if (( ! $+commands[docker] )); then
return 1
fi
#
# Functions
#
# Set Docker Machine environment
function dkme {
if (( ! $+commands[docker-machine] )); then
return 1
fi
eval $(docker-machine env $1)
}
# Set Docker Machine default machine
function dkmd {
if (( ! $+commands[docker-machine] )); then
return 1
fi
pushd ~/.docker/machine/machines
if [[ ! -d $1 ]]; then
echo "Docker machine '$1' does not exists. Abort."
popd
return 1
fi
if [[ -L default ]]; then
eval $(rm -f default)
elif [[ -d default ]]; then
echo "A default manchine already exists. Abort."
popd
return 1
elif [[ -e default ]]; then
echo "A file named 'default' already exists. Abort."
popd
return 1
fi
eval $(ln -s $1 default)
popd
}
# Source plugin files
source "${0:h}/alias.zsh"