commit 1976cad3259e86aa4bc1e9aaa25fd451985020e4
parent af9bfd370faa90966cc75a93feceec7cb5bb2321
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Mon, 10 Feb 2025 18:18:59 +0530
Merge pull request #1997 from psicho2000/feat/improve-autojump
feat: improve autojump
Diffstat:
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/plugins/autojump b/plugins/autojump
@@ -15,7 +15,7 @@
# to make z.lua work, you need to set $NNN_ZLUA to the path of script z.lua
#
# Shell: POSIX compliant
-# Authors: Marty Buchaus, Dave Snider, Tim Adler, Nick Waywood
+# Authors: Marty Buchaus, Dave Snider, Tim Adler, Nick Waywood, Markus Meier
if [ ! -p "$NNN_PIPE" ]; then
printf 'ERROR: NNN_PIPE is not set!'
@@ -24,33 +24,35 @@ if [ ! -p "$NNN_PIPE" ]; then
fi
if type jump >/dev/null 2>&1; then
- printf "jump to : "
+ printf "jump to: "
IFS= read -r line
# shellcheck disable=SC2086
odir="$(jump cd ${line})"
printf "%s" "0c$odir" > "$NNN_PIPE"
elif type autojump >/dev/null 2>&1; then
- printf "jump to : "
+ printf "jump to: "
read -r dir
odir="$(autojump "$dir")"
printf "%s" "0c$odir" > "$NNN_PIPE"
elif type zoxide >/dev/null 2>&1; then
if type fzf >/dev/null 2>&1; then
- odir="$(zoxide query -i --)"
- printf "%s" "0c$odir" > "$NNN_PIPE"
+ odir="$(zoxide query -i --)"
+ printf "%s" "0c$odir" > "$NNN_PIPE"
else
- printf "jump to : "
- read -r dir
- odir="$(zoxide query -- "$dir")"
- printf "%s" "0c$odir" > "$NNN_PIPE"
+ printf "jump to: "
+ read -r dir
+ odir="$(zoxide query -- "$dir")"
+ printf "%s" "0c$odir" > "$NNN_PIPE"
fi
elif type lua >/dev/null 2>&1 && [ -n "$NNN_ZLUA" ]; then
- printf "jump to : "
- read -r line
if type fzf >/dev/null 2>&1; then
- odir="$(lua "$NNN_ZLUA" -l "$line" | fzf --nth 2.. --reverse --inline-info --tac +s -e --height 35%)"
- printf "%s" "0c$(echo "$odir" | awk '{print $2}')" > "$NNN_PIPE"
+ odir="$(lua "$NNN_ZLUA" -l \
+ | awk '{print $2}' \
+ | fzf --nth -1 --delimiter=/ --reverse --inline-info --tac +s -e --height 35%)"
+ printf "0c%s" "$odir" > "$NNN_PIPE"
else
+ printf "jump to: "
+ read -r line
odir="$(lua "$NNN_ZLUA" -e "$line")"
printf "%s" "0c$odir" > "$NNN_PIPE"
fi