diff --git a/doc.md b/doc.md index b9cbeecc..3466a65e 100644 --- a/doc.md +++ b/doc.md @@ -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 diff --git a/doc.txt b/doc.txt index 441d9180..1f55139d 100644 --- a/doc.txt +++ b/doc.txt @@ -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 diff --git a/lf.1 b/lf.1 index d339eee9..332663c6 100644 --- a/lf.1 +++ b/lf.1 @@ -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