aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/fzz
diff options
context:
space:
mode:
authorGravatar step <step-@users.noreply.github.com>2020-05-01 11:36:19 +0200
committerGravatar GitHub <noreply@github.com>2020-05-01 15:06:19 +0530
commit49eecd768485eafed49e6deb8567a54edb7233d0 (patch)
treee9535c30d24635641cefe5eaaf1d87276ea5eaaf /plugins/fzz
parent73e3f2bca015d1ff261e24acdecb5283b35e53b9 (diff)
downloadnnn-49eecd768485eafed49e6deb8567a54edb7233d0.tar.gz
Support $_Z_DATA environment variable (#545)
Support `$_Z_DATA` environment variable per z's documentation https://github.com/rupa/z/blob/dcd5541e7dc37a3a32885565539c6fb1479af26f/z.1#L78. `$_Z_DATA` allows changing the default location of the z database file.
Diffstat (limited to 'plugins/fzz')
-rwxr-xr-xplugins/fzz7
1 files changed, 4 insertions, 3 deletions
diff --git a/plugins/fzz b/plugins/fzz
index f84a064..fa432c1 100755
--- a/plugins/fzz
+++ b/plugins/fzz
@@ -15,11 +15,12 @@ else
exit 1
fi
-if [ -f "$HOME/.z" ]; then
+datafile="${_Z_DATA:-$HOME/.z}"
+if [ -f "$datafile" ]; then
# 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
- sel=$(awk -F "|" '{print $1}' "$HOME/.z" | "$fuzzy" | awk '{$1=$1};1')
+ sel=$(awk -F "|" '{print $1}' "$datafile" | "$fuzzy" | awk '{$1=$1};1')
# NOTE: Uncomment this line and comment out the line above if you want to see the weightings of the dir's in the fzf/fzy pane
- # sel=$(awk -F "|" '{printf "%s %s\n", $2, $1}' "$HOME/.z" | "$fuzzy" | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1')
+ # sel=$(awk -F "|" '{printf "%s %s\n", $2, $1}' "$datafile" | "$fuzzy" | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1')
else
exit 1
fi