From fe30aae0bac0e1191562179ab3734ff9aca0889a Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Wed, 27 Sep 2023 17:16:47 +0300 Subject: [PATCH] Configure zsh to emic OSC7 CWD updates to terminal --- .config/zsh/functions/osc7-pwd.zsh | 12 ++++++++++++ .zshrc | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 .config/zsh/functions/osc7-pwd.zsh diff --git a/.config/zsh/functions/osc7-pwd.zsh b/.config/zsh/functions/osc7-pwd.zsh new file mode 100644 index 0000000..f5a6df1 --- /dev/null +++ b/.config/zsh/functions/osc7-pwd.zsh @@ -0,0 +1,12 @@ +function osc7-pwd() { + emulate -L zsh # also sets localoptions for us + setopt extendedglob + local LC_ALL=C + printf '\e]7;file://%s%s\e\' $HOST ${PWD//(#m)([^@-Za-z&-;_~])/%${(l:2::0:)$(([##16]#MATCH))}} +} + +function chpwd-osc7-pwd() { + (( ZSH_SUBSHELL )) || osc7-pwd +} +add-zsh-hook -Uz chpwd chpwd-osc7-pwd + diff --git a/.zshrc b/.zshrc index d72870d..44a1928 100644 --- a/.zshrc +++ b/.zshrc @@ -53,6 +53,10 @@ zstyle ':prompt:grml:right:setup' use-rprompt false # https://unix.stackexchange.com/a/302710 #set +o prompt_cr +o prompt_sp +# Tell to the terminal about our current working directory +# NB: turns out that alacritty snopps that info from /proc/PID/cwd +xsource ~/.config/zsh/functions/osc7-pwd.zsh + # enable OSC 133 shell prompt start/end reporting # so that the terminal can scroll jump between prompts xsource ~/.config/zsh/functions/semantic-prompt.zsh