1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2025-10-14 15:49:09 +00:00

Feat (docker): add docker aliases (#1147)

Thanks to @malikoth and @saoula for their input.
This commit is contained in:
François VANTOMME
2017-04-13 12:14:23 +02:00
committed by Kaleb Elwert
parent bb168c5881
commit 8a4333103d
3 changed files with 424 additions and 0 deletions

57
modules/docker/init.zsh Normal file
View File

@@ -0,0 +1,57 @@
#
# Defines Docker aliases.
#
# Author:
# François Vantomme <akarzim@gmail.com>
#
# 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 machine 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 module files.
source "${0:h}/alias.zsh"