Created
August 24, 2014 16:55
-
-
Save runjak/1c76dc9e3fcda878c7c9 to your computer and use it in GitHub Desktop.
A script to setup a tmux session with ssh connections to multiple hosts
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/sh | |
SESSION="sessionName" | |
# Creating the tmux session: | |
tmux new-session -d -s $SESSION | |
# Disable renaming of windows: | |
tmux set-option -t $SESSION -g allow-rename off | |
# Function to open a window and connect to a target: | |
# Parameters are window name, target ip | |
open (){ | |
tmux new-window -t $SESSION -n $1 | |
tmux send-keys -t $SESSION "ssh $2" C-m | |
} | |
# Opening windows and connecting to targets: | |
open "host1" "192.168.0.1" | |
open "host2" "192.168.0.2" | |
# Closing first, empty window: | |
tmux select-window -t $SESSION:0 | |
tmux send-keys "exit" C-m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment