When lf -remote is called on startup, the command doesn't work unless a delay is added, for example:
# lfrc
cmd on-cd &{{
bash -c '
source /usr/share/git/completion/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM=1
GIT_PS1_STATESEPARATOR=" "
GIT_PS1_DESCRIBE_STYLE=1
GIT_PS1_SHOWCOLORHINTS=1
git=$(__git_ps1 " %s")
fmt="\033[106m%u@%h\033[00m \033[01;40m%d%f$git\033[0m"
sleep 0.05
lf -remote "send $id set promptfmt \"$fmt\""
notify-send "on-cd" "$fmt"
'
}}
on-cd
Without the sleep 0.05 it doesn't set the promptfmt if lf is launched in a git directory, while manually cding back and forth does set the prompt correctly.
I have the same issue with on-select:
# lfrc
cmd on-select &{{
on_select="" # used by ruler.go
mime=$(file --mime-type -Lb -- "$f")
case "$mime" in
audio/*)
on_select=$(mediainfo --Output="Audio;%BitRate/String% %Duration/String%" "$f")
;;
image/*)
on_select=$(exiftool -s3 -imagesize -- "$f")
;;
video/*)
on_select=$(mediainfo --Output="Video;%Width%x%Height% %Duration/String%" "$f")
;;
text/*)
on_select=$(wc -l "$f" | cut -d' ' -f1)
;;
inode/directory)
on_select=$(du -hs "$f" | cut -f1)
;;
esac
sleep 0.1
if [ -n "$on_select" ]; then
lf -remote "send $id :set user_on_select \"[$on_select]\""
else # clear previous value
lf -remote "send $id :set user_on_select ''"
fi
}}
on-select
I have to add sleep 0.1 for it to set the UserOptions.on_select on lf's startup.
These variables have been set correctly by that time, but remote commands seem to not have effects. I cannot see anything related from the logs.
When
lf -remoteis called on startup, the command doesn't work unless a delay is added, for example:Without the
sleep 0.05it doesn't set thepromptfmtif lf is launched in a git directory, while manually cding back and forth does set the prompt correctly.I have the same issue with
on-select:I have to add
sleep 0.1for it to set theUserOptions.on_selecton lf's startup.These variables have been set correctly by that time, but remote commands seem to not have effects. I cannot see anything related from the logs.