From a0f53489fa5fa942e1b8a8277cf0fdd2cb98bce7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 18 Jun 2025 16:09:46 +0200 Subject: [PATCH] feat(zsh): attach to or create tmux session in interactive shells --- shell/zsh.nix | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/shell/zsh.nix b/shell/zsh.nix index 76710fd..9f415bd 100644 --- a/shell/zsh.nix +++ b/shell/zsh.nix @@ -1,8 +1,13 @@ -{ pkgs, theme, ... }: -let - zsh_autosuggest_highlight_style = if theme == "light" then "fg=180" else "fg=10"; -in { + pkgs, + theme, + ... +}: let + zsh_autosuggest_highlight_style = + if theme == "light" + then "fg=180" + else "fg=10"; +in { programs.zsh = { enable = true; enableCompletion = true; @@ -14,6 +19,15 @@ in }; initContent = '' + # Auto-start tmux if conditions are met + if [[ -z "$TMUX" && -z "$SSH_TTY" && $- == *i* ]]; then + # Check if tmux is available and terminal supports it + if command -v tmux >/dev/null 2>&1; then + # Try to attach to existing session, or create new one + exec tmux new-session -A -s default + fi + fi + function set_win_title(){ local TITLE=$(git config --get remote.origin.url || echo "$PWD") echo -ne "\033]0; $(basename "$TITLE") \007"