Do you have a rule for tmux windows? For example, on which window do you start your editor? Here is my rule.
- Window 0: reposh
- Window 1: vim
- Window 2: zsh
- Window 3: Server process (i.e.
It means that everytime I start tmux, I open 4 windows and run these. Today I learned to do it automatically.
The first step is to write a tmux command file. This is a list of tmux commands that I want to run:
$ cat ~/proj/dotfiles/tools/tmux_multi new-window new-window new-window select-window -t 0 send-keys 'reposh' Enter select-window -t 1 send-keys 'vim' Enter
Then you can load this file at tmux startup by:
$ tmux new-session ";" source-file ~/proj/dotfiles/tools/tmux_multi
Of course this is too long to remember. So I added an alias to my
alias tmux!='tmux new-session ";" source-file ~/proj/dotfiles/tools/tmux_multi'
Now my tmux sets up the 4 windows by
If you are using iTerm2 on Mac, it is useful to set the tab title before starting tmux.
alias tmux!='TAB_NAME=`ruby -e "print Dir.pwd.split(\"/\").last"`; echo -ne "\e]1;$TAB_NAME\a"; tmux new-session ";" source-file ~/proj/dotfiles/tools/tmux_multi'