1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

Improve dsh and drsh functions to work with users, containers and images

This commit is contained in:
Joe Groocock 2016-12-18 12:29:51 +00:00
parent b6bebda784
commit 5a64e0ba98

17
aliases
View File

@ -146,17 +146,20 @@ alias dlg='docker logs -f'
alias dalpine='docker run -ti --rm alpine /bin/sh' alias dalpine='docker run -ti --rm alpine /bin/sh'
alias drm-stopped='docker rm -v $(docker ps -a -q -f status=exited)' alias drm-stopped='docker rm -v $(docker ps -a -q -f status=exited)'
alias drmi-untag='docker rmi $(docker images -f "dangling=true" -q)' alias drmi-untag='docker rmi $(docker images -f "dangling=true" -q)'
dsh() { alias dsh='_dsh exec'
user=`echo $1 | cut -d'@' -f1 -s` alias drsh='_dsh "run --rm"'
if [[ -z "$user" ]]; then _dsh() {
host="$1" local dowhat="$1"
usercmd="" local user=`echo $2 | cut -d'@' -f1 -s`
local usercmd=""
if [ -z "$user" ]; then
host="$2"
else else
host=`echo $1 | cut -d'@' -f2 -s` host=`echo $2 | cut -d'@' -f2 -s`
usercmd="--user=$user " usercmd="--user=$user "
fi fi
eval "docker exec -ti $usercmd$host /bin/sh" eval "docker $dowhat -ti $usercmd$host /bin/sh"
} }
alias dm='docker-machine' alias dm='docker-machine'