Skip to content

Commit

Permalink
dirp hook: dash compatibility
Browse files Browse the repository at this point in the history
This sacrifices one-line ZSH installability
on some systems.
  • Loading branch information
avindra committed Jan 28, 2021
1 parent b20b66a commit 38e069a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ func PrintHook() {
// 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
unalias dir
fi
unalias dir >/dev/null 2>&1
_DIRP_CD=cd
type pushd &> /dev/null && _DIRP_CD=pushd
type pushd >/dev/null 2>&1 && _DIRP_CD=pushd
function dir() {
dir () {
stdout=$(dirp $@)
stat=$?
if [[ -n $stdout ]]; then
if [[ $stat -eq 2 ]]; then
if [ -n $stdout ]; then
if [ $stat -eq 2 ]; then
$EDITOR "$stdout"
return $?
fi
Expand All @@ -37,7 +34,7 @@ function dir() {
fi
}
export -f dir &> /dev/null`)
export -f dir >/dev/null 2>&1`)
}

// PrintFishHook emits shell code for Fish
Expand Down

0 comments on commit 38e069a

Please sign in to comment.