Update examples for on-load (#2020)

This commit is contained in:
CatsDeservePets authored and GitHub committed 2025-06-26 16:09:11 +10:00
1 parent e47600e428
commit 0639e71171
3 files changed
+88 -11

No files matched your search

+29 -4
View File
@@ -1706,7 +1706,7 @@ If you want to send escape sequences to the terminal, you can use the `tty-write
The following xterm-specific escape sequence sets the terminal title to the working directory:
cmd on-cd &{{
lf -remote "send $id tty-write \"\033]0;$PWD\007\""
lf -remote "send $id tty-write \"\033]0;$PWD\007\""
}}
This command runs whenever you change the directory but not on startup.
@@ -1741,13 +1741,38 @@ The following example can be used to display git indicators in the info column:
status=$(git status --porcelain --ignored -- "$file" | cut -c1-2 | head -n1)
if [ -n "$status" ]; then
cmds="${cmds}addcustominfo ${file} \"$status\"; "
cmds="${cmds}addcustominfo \"${file}\" \"$status\"; "
else
cmds="${cmds}addcustominfo ${file} ''; "
cmds="${cmds}addcustominfo \"${file}\" ''; "
fi
done
lf -remote "send $id :$cmds"
if [ -n "$cmds" ]; then
lf -remote "send $id :$cmds"
fi
}}
Another use case could be showing the dimensions of images and videos:
cmd on-load &{{
cmds=""
for file in "$@"; do
mime=$(file --mime-type -Lb -- "$file")
case "$mime" in
# vector images cause problems
image/svg+xml)
;;
image/*|video/*)
dimensions=$(exiftool -s3 -imagesize -- "$file")
cmds="${cmds}addcustominfo \"${file}\" \"$dimensions\"; "
;;
esac
done
if [ -n "$cmds" ]; then
lf -remote "send $id :$cmds"
fi
}}
# COLORS
+28 -3
View File
@@ -1961,13 +1961,38 @@ column:
status=$(git status --porcelain --ignored -- "$file" | cut -c1-2 | head -n1)
if [ -n "$status" ]; then
cmds="${cmds}addcustominfo ${file} \"$status\"; "
cmds="${cmds}addcustominfo \"${file}\" \"$status\"; "
else
cmds="${cmds}addcustominfo ${file} ''; "
cmds="${cmds}addcustominfo \"${file}\" ''; "
fi
done
lf -remote "send $id :$cmds"
if [ -n "$cmds" ]; then
lf -remote "send $id :$cmds"
fi
}}
Another use case could be showing the dimensions of images and videos:
cmd on-load &{{
cmds=""
for file in "$@"; do
mime=$(file --mime-type -Lb -- "$file")
case "$mime" in
# vector images cause problems
image/svg+xml)
;;
image/*|video/*)
dimensions=$(exiftool -s3 -imagesize -- "$file")
cmds="${cmds}addcustominfo \"${file}\" \"$dimensions\"; "
;;
esac
done
if [ -n "$cmds" ]; then
lf -remote "send $id :$cmds"
fi
}}
COLORS
+31 -4
View File
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.7.0.2
.\"
.TH "LF" "1" "2025\-06\-24" "" "DOCUMENTATION"
.TH "LF" "1" "2025\-06\-26" "r35\-31\-g4253a28" "DOCUMENTATION"
.SH NAME
lf \- terminal file manager
.SH SYNOPSIS
@@ -1920,13 +1920,40 @@ cmd on\-load &{{
status=$(git status \-\-porcelain \-\-ignored \-\- \(dq$file\(dq | cut \-c1\-2 | head \-n1)
if [ \-n \(dq$status\(dq ]; then
cmds=\(dq${cmds}addcustominfo ${file} \(rs\(dq$status\(rs\(dq; \(dq
cmds=\(dq${cmds}addcustominfo \(rs\(dq${file}\(rs\(dq \(rs\(dq$status\(rs\(dq; \(dq
else
cmds=\(dq${cmds}addcustominfo ${file} \(aq\(aq; \(dq
cmds=\(dq${cmds}addcustominfo \(rs\(dq${file}\(rs\(dq \(aq\(aq; \(dq
fi
done
lf \-remote \(dqsend $id :$cmds\(dq
if [ \-n \(dq$cmds\(dq ]; then
lf \-remote \(dqsend $id :$cmds\(dq
fi
}}
.EE
.PP
Another use case could be showing the dimensions of images and videos:
.IP
.EX
cmd on\-load &{{
cmds=\(dq\(dq
for file in \(dq$\(at\(dq; do
mime=$(file \-\-mime\-type \-Lb \-\- \(dq$file\(dq)
case \(dq$mime\(dq in
# vector images cause problems
image/svg+xml)
;;
image/*|video/*)
dimensions=$(exiftool \-s3 \-imagesize \-\- \(dq$file\(dq)
cmds=\(dq${cmds}addcustominfo \(rs\(dq${file}\(rs\(dq \(rs\(dq$dimensions\(rs\(dq; \(dq
;;
esac
done
if [ \-n \(dq$cmds\(dq ]; then
lf \-remote \(dqsend $id :$cmds\(dq
fi
}}
.EE
.SH COLORS