[.zshrc] Add new alias to kill all docker containers and a function to run docker exec using fzf to choose the container

This commit is contained in:
Daniel Carrillo 2020-01-19 19:12:31 +01:00
parent b2deb86a71
commit 844bbd1223
1 changed files with 10 additions and 0 deletions

10
.zshrc
View File

@ -20,6 +20,7 @@ alias gb="git checkout \$(git branch -vv | fzf +m | awk '{print \$1}')"
alias open='xdg-open'
alias yayU='yay -Suy --noconfirm'
alias mknamedvenv='mkvirtualenv $(basename $PWD) -r requirements.txt'
alias dkillall='docker rm -f $(docker ps -qa)'
##### tilix #####
@ -49,6 +50,15 @@ fzf-file-widget-hidden () {
fd --type f --hidden -I --follow --exclude .git --exclude .cache | fzf
}
dexec () {
local cid
local cmd=${1:-"bash"}
cid=$(docker ps -a | sed 1d | fzf -1 -q "$1" | awk '{print $1}')
[ -n "$cid" ] && docker exec -ti "$cid" $cmd
}
export FZF_DEFAULT_COMMAND="fd --type f --follow -I"
export FZF_DEFAULT_OPTS="-m --reverse --bind 'ctrl-o:execute(xdg-open {})+abort,ctrl-e:execute({})+abort,ctrl-y:execute(echo {} | xclip -selection clipboard -in)+abort'"
export FZF_CTRL_T_OPTS="--no-height --preview '[[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || pygmentize {} 2> /dev/null | head -500'"