From e639accfdcf7182a232a3cdf4f2c7a442cb2e733 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Thu, 1 Feb 2024 09:33:43 +0100 Subject: [PATCH] update lazygit function for lf --- .config/lf/lfrc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 6cb8f60c..c3ea070d 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -13,8 +13,7 @@ set promptfmt "\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m%d\033[35m]\033 set opener=opener cmd pushedit %{{ - echo "Open: " - files=$(read x; echo $x) + echo "Open: " && read files if sh -c '[ -n "$VIM" ]'; then lf -remote "send $id vimopen $files" else @@ -56,8 +55,16 @@ cmd trash &{{ lf -remote "send load" }} -cmd lazygit &{{ - lf -remote "send $id \$cd "$(dirname "$(realpath "$f")")" && lazygit" +cmd lazygit %{{ + dir=$(dirname "$(realpath "${f:-_}")"}) + if ! git --noglob-pathspecs -C $dir status >/dev/null 2>&1; then + echo "Initialize git repo in '${dir}' [Y/n]:" && read yn && + case $yn in + "" | [Yy]*) git -C ${dir} init >/dev/null 2>&1; break ;; + [Nn]*) ;; + esac + fi + lf -remote "send $id \$cd '$dir' && lazygit" }} # y (select for copy) and P to paste soft-link