1
0
Fork 0

update lazygit function for lf

This commit is contained in:
Luca Bilke 2024-02-01 09:33:43 +01:00
parent 31763757d4
commit e639accfdc
1 changed files with 11 additions and 4 deletions

View File

@ -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