2020-04-02 05:24:24 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# Description: cd to any dir in the z database using an fzf pane
|
|
|
|
#
|
|
|
|
# Shell: POSIX compliant
|
|
|
|
# Author: Nick Waywood
|
|
|
|
|
|
|
|
. "$(dirname "$0")"/.nnn-plugin-helper
|
|
|
|
|
|
|
|
if which fzf >/dev/null 2>&1; then
|
|
|
|
fuzzy=fzf
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-05-01 09:36:19 +00:00
|
|
|
datafile="${_Z_DATA:-$HOME/.z}"
|
|
|
|
if [ -f "$datafile" ]; then
|
2020-04-02 05:24:24 +00:00
|
|
|
# I read the data from z's file instead of calling the z command so that the data doesn't need to be processed twice
|
2020-05-01 09:36:19 +00:00
|
|
|
sel=$(awk -F "|" '{print $1}' "$datafile" | "$fuzzy" | awk '{$1=$1};1')
|
2020-05-06 13:11:01 +00:00
|
|
|
# NOTE: Uncomment this line and comment out the line above if you want to see the weightings of the dir's in the fzf pane
|
2020-05-01 09:36:19 +00:00
|
|
|
# sel=$(awk -F "|" '{printf "%s %s\n", $2, $1}' "$datafile" | "$fuzzy" | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1')
|
2020-04-02 05:24:24 +00:00
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-05-03 09:25:33 +00:00
|
|
|
printf "%s" "0c$sel" > "$NNN_PIPE"
|