From 41dbda027d12212a5a65eb132a86e9d4c650aa0c Mon Sep 17 00:00:00 2001 From: Tobias Ostner Date: Fri, 14 Jun 2024 10:00:49 +0200 Subject: [PATCH] Enable vterm directory and prompt tracking --- nix/config/zsh/zshrc | 19 +++++++++++++++++++ nix/module/home-manager.nix | 4 +--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 nix/config/zsh/zshrc diff --git a/nix/config/zsh/zshrc b/nix/config/zsh/zshrc new file mode 100644 index 0000000..5fa5586 --- /dev/null +++ b/nix/config/zsh/zshrc @@ -0,0 +1,19 @@ +eval "$(/opt/homebrew/bin/brew shellenv)" + +vterm_printf() { + if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ]); then + # Tell tmux to pass the escape sequences through + printf "\ePtmux;\e\e]%s\007\e\\" "$1" + elif [ "${TERM%%-*}" = "screen" ]; then + # GNU screen (screen, screen-256color, screen-256color-bce) + printf "\eP\e]%s\007\e\\" "$1" + else + printf "\e]%s\e\\" "$1" + fi +} + +vterm_prompt_end() { + vterm_printf "51;A$(whoami)@$(hostname):$(pwd)" +} +setopt PROMPT_SUBST +PROMPT=$PROMPT'%{$(vterm_prompt_end)%}' diff --git a/nix/module/home-manager.nix b/nix/module/home-manager.nix index 2b19dcf..c123432 100644 --- a/nix/module/home-manager.nix +++ b/nix/module/home-manager.nix @@ -173,9 +173,7 @@ enable = true; enableCompletion = true; enableAutosuggestions = true; - initExtra = '' - eval "$(/opt/homebrew/bin/brew shellenv)" - ''; + initExtra = builtins.readFile ../config/zsh/zshrc; syntaxHighlighting.enable = true; shellAliases = { ls = "ls --color=auto -F";