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,11 +16,16 @@
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' {
# 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
@ -47,10 +52,11 @@ if-shell '! tmux has-session -t jd' {
# 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' {
}
# If a default session still exists {{{
if-shell -b 'tmux has-session -t 0' {
# Kill it
kill-session -t 0
}
# }}}
}
# }}}