Last active
February 24, 2017 14:44
-
-
Save calbertts/cec65243e51f25171668c3d7a71504b9 to your computer and use it in GitHub Desktop.
Removes a stopped docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
removec() { | |
export FZF_DEFAULT_OPTS='--height 90% --reverse --border' | |
local container=$((docker ps -a --filter status=exited --format '{{.Names}} => {{.Image}} => EXITED' & docker ps -a --filter status=created --format '{{.Names}} => {{.Image}} => CREATED') | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}') | |
if [[ $container != '' ]]; then | |
echo -e "\n \033[1mDocker container:\033[0m" $container | |
printf " \033[1mAre you sure?: \033[0m" | |
local cmd=$(echo -e "No\nYes" | fzf-tmux --reverse --multi) | |
if [[ $cmd != '' ]]; then | |
if [[ $cmd == 'Yes' ]]; then | |
echo -e " Removing $container ...\n" | |
history -s removec | |
history -s docker rm $container | |
docker rm $container > /dev/null | |
fi | |
fi | |
fi | |
export FZF_DEFAULT_OPTS="" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment