Last active
November 4, 2019 14:29
-
-
Save calbertts/8ce6727d782112fd74e5ef32fbc260e4 to your computer and use it in GitHub Desktop.
Runs a command in a running 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
runinc() { | |
export FZF_DEFAULT_OPTS='--height 90% --reverse --border' | |
local container=$(docker ps --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}') | |
if [[ $container != '' ]]; then | |
echo -e "\n \033[1mDocker container:\033[0m" $container | |
read -e -p $' \e[1mOptions: \e[0m' -i "-it" options | |
if [[ $@ == '' ]]; then | |
read -e -p $' \e[1mCommand: \e[0m' cmd | |
else | |
cmd="$@" | |
fi | |
echo '' | |
history -s runinc "$@" | |
history -s docker exec $options $container $cmd | |
docker exec $options $container $cmd | |
echo '' | |
fi | |
export FZF_DEFAULT_OPTS="" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment