From 0ed78980ef2e82dda50c1d85c094d4cc8638a442 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 30 Apr 2023 15:17:21 +0200 Subject: added nvf function --- config/essentials/zsh/functions.zsh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'config/essentials/zsh/functions.zsh') diff --git a/config/essentials/zsh/functions.zsh b/config/essentials/zsh/functions.zsh index f6169eb..da6df04 100644 --- a/config/essentials/zsh/functions.zsh +++ b/config/essentials/zsh/functions.zsh @@ -13,6 +13,23 @@ vmp() { vimh() { vim -c "help $1" -c 'call feedkeys("\o")' } +nvf() { + local cache="$HOME/.cache/nvf" + local match="$(grep -m1 "$1" "$cache" 2> /dev/null)" + if test ! -f "$match" + then + die "resetting cache..." + match="$(goo | tee "$cache" | grep -m 1 "$1" 2> /dev/null)" + # # Alternative: + # match="$(goo | grep -m 1 "$1" 2> /dev/null | tee -a | "$cache")" + fi + if test -f "$match" + then + vim "$match" && return + else + die "no match." && return 1 + fi +} nnn() { test -z "$NNNLVL" && /usr/bin/nnn "$@" || exit } ranger() { test -z "$RANGER_LEVEL" && /usr/bin/ranger "$@" || exit } -- cgit v1.2.3