From b2f5c0e61ec2a1ce8cf62e3b4fadd25be7b6018a Mon Sep 17 00:00:00 2001 From: Leonora Tindall Date: Thu, 14 Nov 2024 08:33:36 -0600 Subject: [PATCH] Switch to zellij --- rcfiles/zshrc | 35 +++++++++++++++++++++++++++++++++++ timberhearth.nix | 2 +- zellij.nix | 4 ++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/rcfiles/zshrc b/rcfiles/zshrc index a1e0aee..a3005d3 100644 --- a/rcfiles/zshrc +++ b/rcfiles/zshrc @@ -1,3 +1,38 @@ +# set zellij tab title +function current_dir() { + local current_dir=$PWD + if [[ $current_dir == $HOME ]]; then + current_dir="~" + else + current_dir=${current_dir##*/} + fi + + echo $current_dir +} + +function change_tab_title() { + local title=$1 + command nohup zellij action rename-tab $title >/dev/null 2>&1 +} + +function set_tab_to_working_dir() { + local result=$? + local title=$(current_dir) + + change_tab_title $title +} + +function set_tab_to_command_line() { + local cmdline=$1 + change_tab_title $cmdline +} + +if [[ -n $ZELLIJ ]]; then + autoload -Uz add-zsh-hook + add-zsh-hook precmd set_tab_to_working_dir + add-zsh-hook preexec set_tab_to_command_line +fi + # load Cargo if [ -f "$HOME/.cargo/env" ]; then . "$HOME/.cargo/env" diff --git a/timberhearth.nix b/timberhearth.nix index 97ac09a..a539c08 100644 --- a/timberhearth.nix +++ b/timberhearth.nix @@ -11,10 +11,10 @@ in ./ssh.nix ./eza.nix ./jq.nix - ./tmux.nix ./direnv.nix ./syncthing.nix ./fzf.nix + ./zellij.nix ./packages-min.nix ]; diff --git a/zellij.nix b/zellij.nix index ac41b97..9ab224a 100644 --- a/zellij.nix +++ b/zellij.nix @@ -1,5 +1,9 @@ { config, pkgs, ... }: { + home.sessionVariables = { + ZELLIJ_AUTO_EXIT = "true"; + }; + programs.zellij= { enable = true; enableZshIntegration = true;