My goal was to start Terminator, that’s the terminal program I use and the reattach to tmux sessions in the three windows that I have. If I close terminator and started it again I wanted the tmux sessions to reattach to the old ones. And I i close tmux I wanted the same tmux windows to start every time.
Looks like this:
The window upper left is my nmap terminal with 4 tmux windows
The window upper right is my tools terminal with 6 tmux windows
The lower windows is my www scanner terminal with 5 tmux windows
So 1 terminal program with 15 active “shells” no I can work without switching to a new terminator.
How I did this.
- Create a directory under my home thats called tmux
- Create 3 files “nmap.sh”, “tools.sh” and “www.sh”
- Make them executable
- Start Terminator and create the layout that you want in my case see picture below
- Go into pref. and layouts and press save
- Exit and start terminator again
- Open preferences in Terminator and add start program on every window
- Edit ~/.tmux.conf if you want…not needed.
- Done
Files to start the tmux sessions:
#cd tmux/ #ls nmap.sh tools.sh www.sh #cat nmap.sh #!/bin/sh tmux new-session -A -s NMAP -n 'Nmap' -d tmux neww -t NMAP -n '-sC-sV' tmux neww -t NMAP -n '-p-' tmux neww -t NMAP -n 'Custom' tmux selectw -t 0 tmux attach-session -t NMAP #cat tools.sh #!/bin/sh tmux new-session -A -s TOOLS -n 'nc-1' -d tmux neww -t TOOLS -n 'simple www' tmux neww -t TOOLS -n 'github' tmux neww -t TOOLS -n 'github' tmux neww -t TOOLS -n 'ftp' tmux neww -t TOOLS -n 'tools' tmux selectw -t 0 tmux attach-session -t TOOLS #cat www.sh #!/bin/sh tmux new-session -A -s WWW -n 'Web' -d tmux neww -t WWW -n 'dirb' tmux neww -t WWW -n 'gobuster' tmux neww -t WWW -n 'nikto' tmux neww -t WWW -n 'sqlmap' tmux selectw -t 0 tmux attach-session -t WWW #
Terminator prefs to autostart tmux:
My tmux.conf
cat .tmux.conf #set -g default-terminal screen-256color set -g status-keys vi set -g history-limit 1000000 # Improve colors set -g default-terminal 'screen-256color' # Set scrollback buffer to 10000 set -g history-limit 10000 # Customize the status line set -g status-fg green set -g status-bg black # Enable mouse mode (tmux 2.1 and above) set -g mouse on # don't rename windows automatically set-option -g allow-rename off # modes setw -g clock-mode-colour colour5 setw -g mode-style 'fg=colour1 bg=colour18 bold' # THEME # loud or quiet? set -g visual-activity off set -g visual-bell off set -g visual-silence off setw -g monitor-activity off set -g bell-action none # modes setw -g clock-mode-colour colour5 setw -g mode-style 'fg=colour1 bg=colour18 bold' # panes set -g pane-border-style 'fg=colour19 bg=colour0' set -g pane-active-border-style 'bg=colour0 fg=colour9' # statusbar set -g status-position bottom set -g status-justify left set -g status-style 'bg=colour18 fg=colour137 dim' set -g status-left '' set -g status-right '#[fg=colour233,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S ' set -g status-right-length 50 set -g status-left-length 20 setw -g window-status-current-style 'fg=colour1 bg=colour19 bold' setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F ' setw -g window-status-style 'fg=colour9 bg=colour18' setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' # messages set -g message-style 'fg=colour232 bg=colour16 bold' #set -g status-bg black #set -g status-fg white #set -g status-interval 1 #set -g status-left-length 30 #set -g status-left '#[fg=green](#S) #(whoami)' #set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M:%S#[default]'