Preset Tmux Windows

Preset Tmux Windows

To preset Tmux windows, following script can be used. It also issues ssh command to host which has same name as window name.

#!/bin/bash

WINDOWS="window_name1 window_name2 window_name3"

for each in $WINDOWS
do
  if ! tmux has-session -t 0:$each; then
    tmux new-window -n $each ssh $each
  fi
done

tmux attach

References

Restore tmux session after reboot
Check If Window With a Specific Name Exists. If It Does Attach to it; Otherwise Create it and Run Command?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


The reCAPTCHA verification period has expired. Please reload the page.