Improve splitting session for workstation

Attach to session if it already exists
Don't attach to new window/pane by default
Improve usage of TARGET_PANE
Kill default session
…
This commit is contained in:
gardouille 2022-12-12 11:52:32 +01:00
parent aeff9f0396
commit 8b2099aa40
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
2 changed files with 46 additions and 25 deletions

View File

@ -1,30 +1,51 @@
#### Session --------------------------------------------------------------
# -sX : numéro de la session
# -nNOM_TERMINAL : nom du terminal
# -d : indique à tmux de ne pas attacher la session et de ne pas prendre les
# nouvelles fenêtres comme une fenêtre courante
# -tX:Y : modifier les paramètres de la fenêtre Y de la session X. !Attention
# la fenêtre doit exister avant de pouvoir modifier ses paramètres!
### Session --------------------------------------------------------------
# -sXX : XX session ID or name
# -nWINDOW_NAME : Name of the window…
# -d : Don't attache to the new session/window/pane/…
# -tXX:YY.ZZ :
# XX : session ID or name
# YY : (optional) Window ID
# ZZ : (optional) Pane ID
# YY and ZZ should exists to be able to change the parameters,…
# monitor-activity : permet de mettre en avant une fenêtre quand son contenu reçoit un événement
# 'exec ${SHELL}': Allow to keep the pane running after the program exists
# New session for working station
# Manage session named **jd** for working station
# New session with a first window with 2 panes in 42 debops project
new -A -sjd -n42
splitw -h -t1 -c '/home/jegardai/repos/101010.debops'
select-pane -t 1
# Second window with 2 panes in IPR debops project
neww -d -nIPR -c '/home/jegardai/repos/ipr.debops'
select-window -t 2
splitw -h -c '/home/jegardai/repos/ipr.debops'
select-pane -t 1
# Third window in home
#neww -d -c '/home/jegardai/'
# If a session already exists {{{
if-shell -b 'tmux has-session -t jd' {
display-message "Attach to **jd** existing session"
## Attach to the first pane of the first window
attach-session -t jd:1.1
}
# }}}
# If no session already exists
if-shell '! tmux has-session -t jd' {
display-message "Create a new session for Workstation"
# A first window named **42**
new-session -A -sjd -n42
## Split the first window and move to 42 debops project
split-window -d -h -tjd:1.1 -c '/home/jegardai/repos/101010.debops'
## Split again the first window and move to 42 debops project
split-window -v -tjd:1.1 -c '/home/jegardai/repos/101010.debops'
# Kill first pane of the first window
# Little trick to avoid to set this directory as default for any new pane…
kill-pane -tjd:1.1
# Default window: jd:0
select-window -t 1
select-pane -t 1
# Second window named **IPR**
new-window -d -nIPR -c '/home/jegardai/repos/ipr.debops'
# with 2 panes in IPR debops project
split-window -d -h -tjd:2.1 -c '/home/jegardai/repos/ipr.debops'
# Third window in home
#new-window -d
# Kill default created session
kill-session -t 0
# Default window should be jd:1
#select-window -t 1
# Default pane should be jd:1.1
}
# If a default session still exists {{{
if-shell -b 'tmux has-session -t 0' {
# Kill it
kill-session -t 0
}
# }}}

View File

@ -243,7 +243,7 @@ set -g lock-after-time 1800
if 'command -v cmatrix' 'set -g lock-command "cmatrix -s && physlock"' 'set -g lock-command physlock'
# Initialize sessions
bind I source-file ~/.tmux/splitWORKSTATION\; display-message "tmux split for Work"
bind I source-file ~/.tmux/splitWORKSTATION
bind V source-file ~/.tmux/split101010\; display-message "tmux split for 101010"
bind H source-file ~/.tmux/splitHP\; display-message "tmux split for HP"