Skip to content

Commit

Permalink
Merge pull request #1997 from psicho2000/feat/improve-autojump
Browse files Browse the repository at this point in the history
feat: improve autojump
  • Loading branch information
jarun authored Feb 10, 2025
2 parents af9bfd3 + e0ed6c8 commit 1976cad
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions plugins/autojump
Original file line number Diff line number Diff line change
Expand Up @@ -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!'
Expand All @@ -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
Expand Down

0 comments on commit 1976cad

Please sign in to comment.