11.1.19

Tmux automation scripts !!!

I've been at a new infrastructure company, I've been spinning up tons of infrastructure on OpenStack, as well as in  local VMs, each of which is 
serving as a *permanant* vm for my daily hacking.

So, I wanted to get an IDE like feel to my SSH terminals, i.e. one with history and so on.

After some googling, I discovered tmux scripts. 

You can *COMPLETELY* automate all of your SSH targets and window spaces in your terminal via TMUX.

Here's an example:

#!/bin/bash
SESSION=jayunit100

echo "new session..."
tmux -2 new-session -d -s $SESSION

tmux new-window -t $SESSION:1 -n 'Logs1'

echo "created window"

# dev box
tmux select-pane -t 1
tmux send-keys "ssh-add ; ssh -v centos@10.4.252.95" C-m


# p9 DU box
tmux split-window -v
echo "select"
tmux select-pane -t 2
tmux send-keys "ssh-add ; ssh -v jay@jayunit100.platform9.horse" C-m

# slave 1 # centos 26
tmux split-window -v
tmux select-pane -t 3
tmux send-keys "ssh-add ; ssh -v centos@10.5.0.26" C-m

# slave 2 # centos 39
tmux split-window -v
tmux select-pane -t 4
tmux send-keys "ssh-add ; ssh -v centos@10.5.0.39" C-m

tmux -2 attach-session -t $SESSION

No comments:

Post a Comment