From 285343d6ef7d3149beaf942a2f540ccc7610d06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Uruba?= Date: Sun, 30 Nov 2025 16:15:09 +0100 Subject: [PATCH] zsh: Improve chpwd behaviour --- zsh/.zshrc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/zsh/.zshrc b/zsh/.zshrc index 5fc2593..3abf3c4 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -94,12 +94,12 @@ bindkey "^K" kill-line # Ctrl + k bindkey "^U" backward-kill-line # Ctrl + u # save path on cd (chpwd is a zsh hook) and spawned subshell -function chpwd { +function _chpwd { pwd > ~/.last_dir } -if [[ $SHLVL -ge 3 ]]; then - chpwd +if [[ $SHLVL -gt 3 ]]; then + _chpwd fi # restore last saved path on launch @@ -107,6 +107,10 @@ if [[ -f ~/.last_dir ]]; then cd $(cat ~/.last_dir) fi +function chpwd { + _chpwd +} + # save path on quiting nnn (and alias it to 'n') function n { # Block nesting of nnn in subshells