Skip to content

Instantly share code, notes, and snippets.

@Muzietto
Last active April 30, 2023 15:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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!!!
@igbanam
Copy link

igbanam commented May 31, 2022

Thanks for the tip about starting this with tmux attach — I almost lost hair over trying to figure out why I needed an extra session for the configs. Is this documented anywhere but here?

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