From 9bc26cdd31e12ca29f554d0c139d15c52acdf8f6 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 4 Oct 2024 14:52:39 +0200 Subject: [PATCH] Create a new anonymous tmux session on new shell --- modules/cli/zsh/default.nix | 6 ++---- modules/cli/zsh/init.zsh | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/cli/zsh/default.nix b/modules/cli/zsh/default.nix index 02b5037..5ce6719 100644 --- a/modules/cli/zsh/default.nix +++ b/modules/cli/zsh/default.nix @@ -136,20 +136,18 @@ in { plugins = [ "sudo" "git" - "tmux" "kubectl" "copypath" "copyfile" ]; }; + # zprof.enable = true; + sessionVariables = { YSU_MESSAGE_FORMAT = "Alias: %alias - %command"; YSU_IGNORED_ALIASES = ''("g" "-" "~" "/" ".." "..." "...." "....." "md" "rd")''; DIRENV_LOG_FORMAT = ""; - ZSH_TMUX_AUTOSTART = true; - # ZSH_TMUX_AUTONAME_SESSION = false; - # ZSH_TMUX_DEFAULT_SESSION_NAME = "home"; }; }; } diff --git a/modules/cli/zsh/init.zsh b/modules/cli/zsh/init.zsh index aa614dd..9d0a279 100644 --- a/modules/cli/zsh/init.zsh +++ b/modules/cli/zsh/init.zsh @@ -1,3 +1,8 @@ +# Create a new tmux session (with a random name) and attach. +if [[ -z "$TMUX" ]]; then + exec tmux new-session -s "$(hexdump -n 4 -v -e '/1 "%02X"' /dev/urandom)" +fi + if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi