Configuring tmux to automatically create specific window panes and launch scripts/commands when starting...

Category: Software and Systems Engineering
Author: Sean O'Donnell
Wed, Oct. 22nd, 2014 @ 19:35:32 (MDT)

In a follow-up to my previous post regarding 'screen', this example uses 'tmux', instead of screen, to automatically create specific panes and execute specific scripts/commands automatically, within each pane.

# ~/.tmux.conf
set -g default-terminal "screen"
set -g set-remain-on-exit on
set-option -s history-limit 20000
bind y respawn-window
new true
neww -n IRC "irssi"
neww -n httpd-errors "sudo tail -f /var/log/httpd/error_log"
neww -n htop-local "sudo htop"
neww -n top-local "sudo top"
neww -n netstat-local "sudo netstat -taupnc"
neww -n iptstate-local "sudo iptstate"

The file above should be saved to your local $HOME directory, and named ".tmux.conf" (i.e. ~/.tmux.conf)

You can then launch tmux and it will automatically create the new windows while automatically executing the specified command/script for that given window pane.

tmux attach

Note: The commands used in this configuration example assume that you've got the stated programs properly installed on your system. You should probably edit the commands to make it more relevant towards your normal terminal command usage. 

Copyleft (<) 1998-2019