From 7ad37989707cdd1c0c72b7d42b555bb2e86291b5 Mon Sep 17 00:00:00 2001 From: Avindra Goolcharan Date: Wed, 27 Jan 2021 20:48:11 -0500 Subject: [PATCH] dirp hook: ZSH compat Turns out $status is a special reserved var in ZSH. After using a different name, the existing hook is tested as compatible. --- src/hook.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hook.go b/src/hook.go index db761bc..9dc886e 100644 --- a/src/hook.go +++ b/src/hook.go @@ -11,6 +11,9 @@ func PrintHook() { // 2) Detect and prefer pushd over cd // 3) Provide "dir" function // 4) export dir function for Bash users + + // important: do not use $status as a variable + // because it's a readonly reserved special var in ZSH fmt.Println(` alias dir &> /dev/null if [[ $? -eq 0 ]]; then @@ -22,9 +25,9 @@ type pushd &> /dev/null && _DIRP_CD=pushd function dir() { stdout=$(dirp $@) - status=$? + stat=$? if [[ -n $stdout ]]; then - if [[ $status -eq 2 ]]; then + if [[ $stat -eq 2 ]]; then $EDITOR "$stdout" return $? fi