Reputation: 651
I am working on the following script for setting up a tmux window with a very specific pane layout. For reasons I can't figure out, it isn't creating the final pane...
#!/bin/sh
tmux new-session -d -s foo 'htop'
tmux rename-window 'Foo'
tmux select-window -t foo:0
tmux split-window -v 'tail -f logfile1.log'
tmux resize-pane -U 7
tmux split-window -h 'tail -f logfile2.log'
tmux resize-pane -U 7
tmux resize-pane -R 23
tmux select-pane -t 1
tmux split-window -v 'tail -f logfile3.log'
tmux select-pane -t 2
tmux split-window -h 'df -h'
tmux -2 attach-session -t foo
Upvotes: 0
Views: 169
Reputation: 195029
In tmux, if you pass a command when create window, When the shell command completes, the window closes. It behaves same for panes.
In your script, the other panes show because the command/processes are not finished yet (htop, tail -f). To test it, you can change the df -h
into df -h && sleep 20
. Then you will see the pane for 20s.
There is a window option remain-on-exit
, if you set it, the window/pane remains after the command execution finished. The pane/window will be marked "deactived/dead". You can re-active it by command respawn-window
or respawn-pane
If you want it, add this line after your tmux select-window....
:
tmux set-window-option remain-on-exit on
Upvotes: 1