mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
nixos/tmux: use idempotent new-session to avoid duplicate sessions
When both 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:
parent
765cd61a3e
commit
b3b1a85370
1 changed files with 6 additions and 1 deletions
|
|
@ -29,7 +29,12 @@ let
|
|||
setw -g pane-base-index ${toString cfg.baseIndex}
|
||||
set -g history-limit ${toString cfg.historyLimit}
|
||||
|
||||
${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 v split-window -h
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue