Created
February 16, 2017 17:31
-
-
Save dadaphl/f66515f3b64f243e9d838febd4f28024 to your computer and use it in GitHub Desktop.
Opens tmux split for each running docker comtainer and executes command
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
#!/bin/bash | |
# | |
# Opens tmux split for each running docker comtainer and executes command: | |
# Example: | |
# docker-exec-all.sh top | |
# | |
tmux set -g pane-border-status top | |
for line in `docker ps --format '{{.ID}},{{.Names}}'` | |
do | |
IFS=,; | |
read -r -a arr <<< "$line"; | |
tmux split-window -h "printf '\033]2;%s\033\\' '${arr[1]}' && docker exec -it ${arr[0]} $1"; | |
done | |
sleep 1 | |
tmux select-layout even-horizontal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment