Skip to content

Commit 38e069a

Browse files
committed
dirp hook: dash compatibility
This sacrifices one-line ZSH installability on some systems.
1 parent b20b66a commit 38e069a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/hook.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@ func PrintHook() {
1515
// important: do not use $status as a variable
1616
// because it's a readonly reserved special var in ZSH
1717
fmt.Println(`
18-
alias dir &> /dev/null
19-
if [[ $? -eq 0 ]]; then
20-
unalias dir
21-
fi
18+
unalias dir >/dev/null 2>&1
2219
2320
_DIRP_CD=cd
24-
type pushd &> /dev/null && _DIRP_CD=pushd
21+
type pushd >/dev/null 2>&1 && _DIRP_CD=pushd
2522
26-
function dir() {
23+
dir () {
2724
stdout=$(dirp $@)
2825
stat=$?
29-
if [[ -n $stdout ]]; then
30-
if [[ $stat -eq 2 ]]; then
26+
if [ -n $stdout ]; then
27+
if [ $stat -eq 2 ]; then
3128
$EDITOR "$stdout"
3229
return $?
3330
fi
@@ -37,7 +34,7 @@ function dir() {
3734
fi
3835
}
3936
40-
export -f dir &> /dev/null`)
37+
export -f dir >/dev/null 2>&1`)
4138
}
4239

4340
// PrintFishHook emits shell code for Fish

0 commit comments

Comments
 (0)