Skip to content

Instantly share code, notes, and snippets.

@dadaphl
Created February 16, 2017 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadaphl/f66515f3b64f243e9d838febd4f28024 to your computer and use it in GitHub Desktop.
Save dadaphl/f66515f3b64f243e9d838febd4f28024 to your computer and use it in GitHub Desktop.
Opens tmux split for each running docker comtainer and executes command
#!/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