feat(zsh): attach to or create tmux session in interactive shells

This commit is contained in:
Michael Mandl 2025-06-18 16:09:46 +02:00
parent b437553ce3
commit a0f53489fa
Signed by: mandlm
GPG key ID: 088ED38F036C7AF2

View file

@ -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 = { programs.zsh = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
@ -14,6 +19,15 @@ in
}; };
initContent = '' 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(){ function set_win_title(){
local TITLE=$(git config --get remote.origin.url || echo "$PWD") local TITLE=$(git config --get remote.origin.url || echo "$PWD")
echo -ne "\033]0; $(basename "$TITLE") \007" echo -ne "\033]0; $(basename "$TITLE") \007"