aboutsummaryrefslogtreecommitdiff
path: root/files/.config/nnn/plugins/autojump
diff options
context:
space:
mode:
Diffstat (limited to 'files/.config/nnn/plugins/autojump')
-rwxr-xr-xfiles/.config/nnn/plugins/autojump28
1 files changed, 15 insertions, 13 deletions
diff --git a/files/.config/nnn/plugins/autojump b/files/.config/nnn/plugins/autojump
index 6a24a52..795c434 100755
--- a/files/.config/nnn/plugins/autojump
+++ b/files/.config/nnn/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