Skip to content

Commit 1976cad

Browse files
authored
Merge pull request #1997 from psicho2000/feat/improve-autojump
feat: improve autojump
2 parents af9bfd3 + e0ed6c8 commit 1976cad

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

plugins/autojump

+15-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# to make z.lua work, you need to set $NNN_ZLUA to the path of script z.lua
1616
#
1717
# Shell: POSIX compliant
18-
# Authors: Marty Buchaus, Dave Snider, Tim Adler, Nick Waywood
18+
# Authors: Marty Buchaus, Dave Snider, Tim Adler, Nick Waywood, Markus Meier
1919

2020
if [ ! -p "$NNN_PIPE" ]; then
2121
printf 'ERROR: NNN_PIPE is not set!'
@@ -24,33 +24,35 @@ if [ ! -p "$NNN_PIPE" ]; then
2424
fi
2525

2626
if type jump >/dev/null 2>&1; then
27-
printf "jump to : "
27+
printf "jump to: "
2828
IFS= read -r line
2929
# shellcheck disable=SC2086
3030
odir="$(jump cd ${line})"
3131
printf "%s" "0c$odir" > "$NNN_PIPE"
3232
elif type autojump >/dev/null 2>&1; then
33-
printf "jump to : "
33+
printf "jump to: "
3434
read -r dir
3535
odir="$(autojump "$dir")"
3636
printf "%s" "0c$odir" > "$NNN_PIPE"
3737
elif type zoxide >/dev/null 2>&1; then
3838
if type fzf >/dev/null 2>&1; then
39-
odir="$(zoxide query -i --)"
40-
printf "%s" "0c$odir" > "$NNN_PIPE"
39+
odir="$(zoxide query -i --)"
40+
printf "%s" "0c$odir" > "$NNN_PIPE"
4141
else
42-
printf "jump to : "
43-
read -r dir
44-
odir="$(zoxide query -- "$dir")"
45-
printf "%s" "0c$odir" > "$NNN_PIPE"
42+
printf "jump to: "
43+
read -r dir
44+
odir="$(zoxide query -- "$dir")"
45+
printf "%s" "0c$odir" > "$NNN_PIPE"
4646
fi
4747
elif type lua >/dev/null 2>&1 && [ -n "$NNN_ZLUA" ]; then
48-
printf "jump to : "
49-
read -r line
5048
if type fzf >/dev/null 2>&1; then
51-
odir="$(lua "$NNN_ZLUA" -l "$line" | fzf --nth 2.. --reverse --inline-info --tac +s -e --height 35%)"
52-
printf "%s" "0c$(echo "$odir" | awk '{print $2}')" > "$NNN_PIPE"
49+
odir="$(lua "$NNN_ZLUA" -l \
50+
| awk '{print $2}' \
51+
| fzf --nth -1 --delimiter=/ --reverse --inline-info --tac +s -e --height 35%)"
52+
printf "0c%s" "$odir" > "$NNN_PIPE"
5353
else
54+
printf "jump to: "
55+
read -r line
5456
odir="$(lua "$NNN_ZLUA" -e "$line")"
5557
printf "%s" "0c$odir" > "$NNN_PIPE"
5658
fi

0 commit comments

Comments
 (0)