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:
Jeremy Gardais 2022-12-12 11:52:32 +01:00
parent aeff9f0396
commit 8b2099aa40
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
2 changed files with 46 additions and 25 deletions

View File

@ -1,30 +1,51 @@
#### Session -------------------------------------------------------------- ### Session --------------------------------------------------------------
# -sX : numéro de la session # -sXX : XX session ID or name
# -nNOM_TERMINAL : nom du terminal # -nWINDOW_NAME : Name of the window…
# -d : indique à tmux de ne pas attacher la session et de ne pas prendre les # -d : Don't attache to the new session/window/pane/…
# nouvelles fenêtres comme une fenêtre courante # -tXX:YY.ZZ :
# -tX:Y : modifier les paramètres de la fenêtre Y de la session X. !Attention # XX : session ID or name
# la fenêtre doit exister avant de pouvoir modifier ses paramètres! # 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 # 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 # '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 # If a session already exists {{{
new -A -sjd -n42 if-shell -b 'tmux has-session -t jd' {
splitw -h -t1 -c '/home/jegardai/repos/101010.debops' display-message "Attach to **jd** existing session"
select-pane -t 1 ## Attach to the first pane of the first window
# Second window with 2 panes in IPR debops project attach-session -t jd:1.1
neww -d -nIPR -c '/home/jegardai/repos/ipr.debops' }
select-window -t 2 # }}}
splitw -h -c '/home/jegardai/repos/ipr.debops' # If no session already exists
select-pane -t 1 if-shell '! tmux has-session -t jd' {
# Third window in home display-message "Create a new session for Workstation"
#neww -d -c '/home/jegardai/' # 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 # Second window named **IPR**
select-window -t 1 new-window -d -nIPR -c '/home/jegardai/repos/ipr.debops'
select-pane -t 1 # 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 # Default window should be jd:1
kill-session -t 0 #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' if 'command -v cmatrix' 'set -g lock-command "cmatrix -s && physlock"' 'set -g lock-command physlock'
# Initialize sessions # 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 V source-file ~/.tmux/split101010\; display-message "tmux split for 101010"
bind H source-file ~/.tmux/splitHP\; display-message "tmux split for HP" bind H source-file ~/.tmux/splitHP\; display-message "tmux split for HP"