From b4b611faea71bd6926749520f7edb8cbe63c1c51 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Mon, 12 Dec 2022 12:06:13 +0100 Subject: [PATCH] Same improvements for laptop and work splits --- splitLAPTOP | 61 ++++++++++++++++++++++++++++++++++--------------- splitWORK | 32 ++++++++++++++++++++++---- tmux.conf.local | 4 ++-- 3 files changed, 72 insertions(+), 25 deletions(-) diff --git a/splitLAPTOP b/splitLAPTOP index 6c68383..efdbbfd 100644 --- a/splitLAPTOP +++ b/splitLAPTOP @@ -1,23 +1,48 @@ -#### 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 with first window in ~ -new -A -stoto -nmail 'mutt ; exec ${SHELL}' -splitw -h -p 25 -t 1 'sudo aptitude update ; sudo aptitude full-upgrade ; exec ${SHELL}' -# New window toto:1 with btop (refresh every minute) -neww -d -nXt0p 'btop ; exec ${SHELL}' -# New window toto:2 for remote weechat -neww -d -nw33 'weechat ; exec ${SHELL}' -# New window toto:3 for git repositories -neww -d -ngit -c '/home/jegardai/repos' +# Manage session named **toto** for laptop -# Default window: toto:3 -select-window -t 3 +# If a session already exists {{{ +if-shell -b 'tmux has-session -t toto' { + display-message "Attach to **toto** existing session" + ## Attach to the first pane of the first window + attach-session -t toto:1.1 +} +# }}} +# If no session already exists +if-shell '! tmux has-session -t toto' { + display-message "Create a new session for Laptop" + # A first window named **mail** + # with mutt running in the first pane + new-session -A -stoto -nmail 'mutt ; exec ${SHELL}' + ## Split the first window for APT upgrade + split-window -h -p 25 -ttoto:1.1 'sudo aptitude update ; sudo aptitude full-upgrade ; exec ${SHELL}' +# + # Second window named **Xt0p** with btop running + new-window -d -nXt0p 'btop ; exec ${SHELL}' + # Third window named **ch4t** with weechat running + neww -d -nch4t 'weechat ; exec ${SHELL}' + # Fourth window named **git** in main repos directory + new-window -d -ngit -c '/home/jegardai/repos' + # Default window should be jd:1 + #select-window -t 1 + # Default pane should be jd:1.2 + #select-pane -t 2 +} +# If a default session still exists {{{ +if-shell -b 'tmux has-session -t 0' { + # Kill it + kill-session -t 0 +} +# }}} diff --git a/splitWORK b/splitWORK index 34c64a2..327b3d7 100644 --- a/splitWORK +++ b/splitWORK @@ -3,13 +3,35 @@ # -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 -# -t0:X : modifier les paramètres de la fenêtre X de la session 0. !Attention +# -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! # monitor-activity : permet de mettre en avant une fenêtre quand son contenu reçoit un événement -# -new -A -sIPR -nDeLL +# 'exec ${SHELL}' : Allow to keep the pane running after the program exists -neww -d -nCeph +# New session for work -neww -d -nProx7 +# Manage session named **IPR** for work +# If a session already exists {{{ +if-shell -b 'tmux has-session -t IPR' { + display-message "Attach to **IPR** existing session" + ## Attach to the first pane of the first window + attach-session -t IPR:1.1 +} +# }}} +# If no session already exists +if-shell '! tmux has-session -t IPR' { + display-message "Create a new session for Work" + # A first window named **DeLL** + new-session -A -sIPR -nDeLL + + # Second window named **Ceph** + new-window -d -nCeph + + # Third window named **Prox7** + new-window -d -nProx7 + + # Default window should be jd:1 + #select-window -t 1 + # Default pane should be jd:1.1 +} diff --git a/tmux.conf.local b/tmux.conf.local index bdac615..ad0ede7 100644 --- a/tmux.conf.local +++ b/tmux.conf.local @@ -72,6 +72,6 @@ bind-key -T copy-mode-vi 'v' send -X begin-selection bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel # Initialize sessions -bind I source-file ~/.tmux/splitWORK\; display-message "tmux split for Work" -bind H source-file ~/.tmux/splitLAPTOP\; display-message "tmux split for Laptop" +bind I source-file ~/.tmux/splitWORK +bind H source-file ~/.tmux/splitLAPTOP ### }}}