From d09449411b1e910bfbaa28fd298f95a6247422e0 Mon Sep 17 00:00:00 2001 From: thek4n Date: Wed, 3 Apr 2024 14:20:21 +0300 Subject: [PATCH] add tmux systemd service --- home/user/.bashrc | 6 +++++- home/user/.config/systemd/user/tmux.service | 2 +- home/user/.config/zsh/.zshrc | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/home/user/.bashrc b/home/user/.bashrc index 328e1ce..982c77c 100644 --- a/home/user/.bashrc +++ b/home/user/.bashrc @@ -7,7 +7,11 @@ if \ [[ ! "$TERM" =~ tmux ]] && \ command -v tmux &>/dev/null then - exec tmux + if systemctl -q --user is-active tmux; then + exec tmux -N -L "$USER" new + else + exec tmux + fi fi if [ -f "$HOME/.config/bash/sourcer" ]; then diff --git a/home/user/.config/systemd/user/tmux.service b/home/user/.config/systemd/user/tmux.service index ddbec63..9a0d101 100644 --- a/home/user/.config/systemd/user/tmux.service +++ b/home/user/.config/systemd/user/tmux.service @@ -5,7 +5,7 @@ After=default.target [Service] Type=simple -ExecStart=/usr/bin/tmux -D +ExecStart=/usr/bin/tmux -D -L %u ExecStop=/usr/bin/tmux kill-server Restart=on-failure diff --git a/home/user/.config/zsh/.zshrc b/home/user/.config/zsh/.zshrc index c885c3f..e2ad7ba 100644 --- a/home/user/.config/zsh/.zshrc +++ b/home/user/.config/zsh/.zshrc @@ -7,7 +7,11 @@ if \ [[ ! "$TERM" =~ tmux ]] && \ command -v tmux &>/dev/null then - exec tmux + if systemctl -q --user is-active tmux; then + exec tmux -N -L "$USER" new + else + exec tmux + fi fi if [ -f "$ZDOTDIR/sourcer" ]; then