mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
tmux: use idempotent new-session to avoid duplicate sessions
When both system-level (e.g., NixOS programs.tmux) and home-manager tmux configs set newSession = true, tmux would create two sessions on startup since both /etc/tmux.conf and ~/.config/tmux/tmux.conf contain the new-session command. Change new-session to new-session -A -s 0, which attaches to session "0" if it exists, otherwise creates it. This makes the command idempotent so multiple configs can safely enable newSession.
This commit is contained in:
committed by
Austin Horstman
parent
3d822c1dba
commit
6f35bb9799
@@ -57,7 +57,11 @@ let
|
||||
# We need to set default-shell before calling new-session
|
||||
set -g default-shell "${cfg.shell}"
|
||||
''}
|
||||
${optionalString cfg.newSession "new-session"}
|
||||
${optionalString cfg.newSession ''
|
||||
# Use -A to make new-session idempotent: attach if session "0" exists,
|
||||
# otherwise create it. This prevents duplicate sessions when multiple
|
||||
# configs (e.g., system and user) both enable newSession.
|
||||
new-session -A -s 0''}
|
||||
|
||||
${optionalString cfg.reverseSplit ''
|
||||
bind -N "Split the pane into two, left and right" v split-window -h
|
||||
|
||||
@@ -3,7 +3,10 @@ set -g default-terminal "screen"
|
||||
set -g base-index 0
|
||||
setw -g pane-base-index 0
|
||||
|
||||
new-session
|
||||
# Use -A to make new-session idempotent: attach if session "0" exists,
|
||||
# otherwise create it. This prevents duplicate sessions when multiple
|
||||
# configs (e.g., system and user) both enable newSession.
|
||||
new-session -A -s 0
|
||||
|
||||
bind -N "Split the pane into two, left and right" v split-window -h
|
||||
bind -N "Split the pane into two, top and bottom" s split-window -v
|
||||
|
||||
@@ -3,7 +3,10 @@ set -g default-terminal "screen"
|
||||
set -g base-index 0
|
||||
setw -g pane-base-index 0
|
||||
|
||||
new-session
|
||||
# Use -A to make new-session idempotent: attach if session "0" exists,
|
||||
# otherwise create it. This prevents duplicate sessions when multiple
|
||||
# configs (e.g., system and user) both enable newSession.
|
||||
new-session -A -s 0
|
||||
|
||||
bind -N "Split the pane into two, left and right" v split-window -h
|
||||
bind -N "Split the pane into two, top and bottom" s split-window -v
|
||||
|
||||
Reference in New Issue
Block a user