Test if already inside a tmux

This commit is contained in:
gardouille 2022-12-21 09:32:04 +01:00
parent 2b12a22861
commit 729cbff471
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 36 additions and 30 deletions

View File

@ -16,41 +16,47 @@
if-shell -b 'tmux has-session -t jd' {
display-message "Attach to **jd** existing session"
## Attach to the first pane of the first window
## Only works from a running tmux
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
# 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'
# If file was source from a running tmux
# This allow to run tmux source-file command outside of Tmux…
if-shell -b 'test -n $TMUX' {
# 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
# Third window for APT upgrade
new-window -nAPT 'sudo aptitude update ; sudo aptitude full-upgrade ; exec ${SHELL}'
# 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'
# Fourth window for authentication tools
new-window -nAuth 'gpg --quiet --for-your-eyes-only --decrypt ~/.password-store/test.gpg ; logout'
split-window -h 'ssh-add -l | grep -qi -- "(ed25519)" || ssh-add ~/.ssh/id_ed25519 ; logout'
set-window-option synchronize-panes on
# Third window for APT upgrade
new-window -nAPT 'sudo aptitude update ; sudo aptitude full-upgrade ; exec ${SHELL}'
# Default pane should be jd:4.2
#select-pane -tjd:4.2
# Fourth window for authentication tools
new-window -nAuth 'gpg --quiet --for-your-eyes-only --decrypt ~/.password-store/test.gpg ; logout'
split-window -h 'ssh-add -l | grep -qi -- "(ed25519)" || ssh-add ~/.ssh/id_ed25519 ; logout'
set-window-option synchronize-panes on
# Default pane should be jd:4.2
#select-pane -tjd:4.2
}
# If a default session still exists {{{
if-shell -b 'tmux has-session -t 0' {
# Kill it
kill-session -t 0
}
# }}}
}
# If a default session still exists {{{
if-shell -b 'tmux has-session -t 0' {
# Kill it
kill-session -t 0
}
# }}}