I restore common setups for my project with something equivalent to this:
setup_file=myproj.tmux
tmux new-session "tmux source-file $setup_file"
I would normally assume that starting a new session and then sourcing commands from $setup_file
would be equivalent to manually executing those tmux commands in a new shell, but it's not! The difference is that when sourcing, no shell seems to be created in window 0, so when I execute neww
this creates a window 1, but window 0 is missing when everything has been setup. To hack around this I execute split-window
, but I do not understand why I need to do this. Clues?
myproj.tmux
# window 0 - cli
rename-window 'cli';
split-window # not sure why this is needed to get a shell. Otherwise there is no window 0!
# window 1 - main window in the left pane and 3 minor windows in the right pane
neww
rename-window 'tools'
send-keys 'nvim' C-m # editor
split-window -h -p 40 # build window (webpack, etc)
split-window -v -p 80 # cli
split-window -v -p 50 # test runner?
select-pane -L; # select the left pane; nvim