From a3584c6211713fd74dc463cd14944bce9a3eb922 Mon Sep 17 00:00:00 2001 From: DannyDannyDanny Date: Mon, 14 Nov 2022 13:29:35 +0100 Subject: [PATCH] :sparkles: add lfcd script :boom: no check for LF --- .zshrc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.zshrc b/.zshrc index fdf6de8..fd5a8c6 100644 --- a/.zshrc +++ b/.zshrc @@ -125,3 +125,18 @@ fi alias pbpaste="powershell.exe -noprofile Get-Clipboard" alias pbcopy="clip.exe" + +# on exit from lf this function changes directory to last browser fir in lf +lfcd () { + tmp="$(mktemp)" + lf -last-dir-path="$tmp" "$@" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" + if [ -d "$dir" ]; then + if [ "$dir" != "$(pwd)" ]; then + cd "$dir" + fi + fi + fi +}