Skip to content

Instantly share code, notes, and snippets.

@Muzietto
Last active September 27, 2024 13:02
Show Gist options
  • Save Muzietto/325344c2b1b3b723985a85800cafef4f to your computer and use it in GitHub Desktop.
Save Muzietto/325344c2b1b3b723985a85800cafef4f to your computer and use it in GitHub Desktop.
.tmux.conf to create a pane layout at start - NB: launch it with `tmux attach`, and not plain `tmux`
# THIS IS THE PANE LAYOUT CREATED
# pane numbers are relative to the end of the actions
# _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# | pane 0 | pane 1 |
# | | |
# | |- - - - - - - - |
# | | pane 2 |
# | | |
# | |- - - - - - - - |
# | | pane 3 |
# | | |
# | |- - - - - - - - |
# | | pane 4 |
# | | |
# - - - - - - - - - - - - - - - - -
new -s my_sess # create new session
neww -n left # create new window
split-window -h -t left # create pane 0 (left) and pane 1 (to the right)
split-window -v # split pane 1 (current pane) in two --> new pane 2 on the bottom
split-window -v # split pane 2 (current pane) in two --> new pane 3 on the bottom
select-pane -t 1 # go back to upper right pane
split-window -v # split pane 1 (current pane) in two --> all pane numbers are shuffled
# additional commands I am actually not using (but they work!)
#split-window -v 'ls;bash -i' # same as above, but ls is executed in window
#select-pane -t 4 # go to lower right pane
#split-window -h # split pane 4 (current pane) in two horizontally
new -s my_sess
neww -n left
split-window -h -t left 'cd ~/my-working-dir; npm run first-task' # pane will disappear if I CTRL-C the task
split-window -v 'cd ~/my-working-dir; npm start; bash -i' # because of "bash -i", pane won't disappear if I CTRL-C the task
split-window -v # no task running in this new pane
select-pane -t 1
split-window -v 'cd ~/my-working-dir; npm run another-task' # pane will disappear if I CTRL-C the task
# NB: DO NOT set remain-on-exit on ANYWHERE!!!
@jjYBdx4IL
Copy link

Could do something like bash -c "top;bash" to keep the pane open after quitting top. Or bash -c "while true; do top; done"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment