Skip to content

Commit

Permalink
dirp hook: ZSH compat
Browse files Browse the repository at this point in the history
Turns out $status is a special
reserved var in ZSH.

After using a different name, the
existing hook is tested as compatible.
  • Loading branch information
avindra committed Jan 28, 2021
1 parent d34855b commit 7ad3798
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7ad3798

Please sign in to comment.