1
0
Fork 0

lf: switch to ouch, clean up wrappers

This commit is contained in:
Luca Bilke 2025-03-07 17:12:49 +01:00
commit d717166a82
Signed by: luca
GPG key ID: F6E11C9BAA7C82F5
4 changed files with 33 additions and 38 deletions
common
.config
.local/bin

View file

@ -195,9 +195,15 @@ cmd find_project ${{
}} }}
cmd extract ${{ cmd extract ${{
for f in $fx; do set -f
aunpack "$f" ouch decompress $fx
done }}
cmd archivemount ${{
mntdir="${f}.mnt"
mkdir -p -- "$mntdir"
archivemount "$f" "$mntdir"
lf -remote "send $id cd \"$(printf '%s' "$mntdir" | sed 's/\\/\\\\/g;s/"/\\"/g')\""
}} }}
cmd pdf_merge ${{ cmd pdf_merge ${{
@ -262,7 +268,7 @@ map <c-d> confirm_delete
map d cut map d cut
map D &dragon-drop -a -x $fx map D &dragon-drop -a -x $fx
map <c-e> scroll-down map <c-e> scroll-down
map e :set user_multiedit "true" ; open; set user_multiedit "false" map e :set user_multiedit "true"; open; set user_multiedit "false"
map E $sudo -e $f map E $sudo -e $f
map f find map f find
map F find-back map F find-back
@ -304,8 +310,8 @@ map u :clear; unselect
map <c-v> pushedit map <c-v> pushedit
map v invert map v invert
# map W new_lf_term # map W new_lf_term
map x $$f map x :extract
map X !$f map X :archivemount
map <c-y> scroll-down map <c-y> scroll-down
map y copy map y copy
map Y &echo $f | xclip -r -selection c map Y &echo $f | xclip -r -selection c

View file

@ -27,12 +27,8 @@ CHAFA="chafa \
--animate false --animate false
" "
archive1() { archive() {
7z l "$f" | sed 1,11d ouch list -Htyq "$f" | tail -n +2
}
archive2() {
als -- "$f"
} }
csv() { csv() {
@ -46,7 +42,7 @@ docx() {
} }
epub() { epub() {
gnome-epub-thumbnailer -s 1024 "$f" /dev/stdout gnome-epub-thumbnailer -s 1024 "$f" /dev/stdout | $CHAFA
} }
html() { html() {
@ -91,7 +87,7 @@ odt() {
} }
pdf() { pdf() {
pdftoppm -jpeg -f 1 -singlefile "$f" pdftoppm -jpeg -f 1 -singlefile "$f" | $CHAFA
} }
sqlite() { sqlite() {
@ -149,7 +145,11 @@ run() {
if [ -r "$cache" ]; then if [ -r "$cache" ]; then
cat "$cache" cat "$cache"
else else
"$@" | tee -p "$cache" if out=$("$@"); then
printf "%s" "$out" | tee -p "$cache"
else
printf "%s" "$out"
fi
fi fi
} }
@ -158,7 +158,7 @@ preview() {
case "$mimetype" in case "$mimetype" in
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet | */vnd.oasis.opendocument.spreadsheet) run ods ;; */vnd.openxmlformats-officedocument.spreadsheetml.sheet | */vnd.oasis.opendocument.spreadsheet) run ods ;;
*/vnd.sqlite3) run sqlite ;; */vnd.sqlite3) run sqlite ;;
*/x-7z-compressed | */vnd.rar | */x-tar | */zip | */x-java-archive | */x-xz | */gzip) run archive1 ;; */x-7z-compressed | */vnd.rar | */x-tar | */zip | */x-java-archive | */x-xz | */gzip | */x-bzip-compressed-tar | */x-compressed-tar | */x-xz-compressed-tar) run archive ;;
*/epub+zip) run -s epub ;; */epub+zip) run -s epub ;;
image/svg+xml) run -s svg ;; image/svg+xml) run -s svg ;;
image/*) run -s image ;; image/*) run -s image ;;
@ -173,7 +173,6 @@ preview() {
*/msword) run word ;; */msword) run word ;;
*/x-bittorrent) run torrent ;; */x-bittorrent) run torrent ;;
*/x-cd-image) run iso ;; */x-cd-image) run iso ;;
*/x-bzip-compressed-tar | */x-compressed-tar | */x-xz-compressed-tar) run archive2 ;;
*/*lua) run lua ;; */*lua) run lua ;;
*/*yaml) run yaml ;; */*yaml) run yaml ;;
*text*) run text ;; *text*) run text ;;

View file

@ -79,17 +79,15 @@ zle -N sudo-command-line
function lf-wrap() { function lf-wrap() {
LF_DIRFILE="$(mktemp -u)" LF_DIRFILE="$(mktemp -u)"
env lfX -last-dir-path="$LF_DIRFILE" \ lfX -last-dir-path="$LF_DIRFILE" \
-command "set promptfmt \"$(${HOME}/.local/libexec/lf_prompt 2>/dev/null)\"" -command "set promptfmt \"$(${HOME}/.local/libexec/lf_prompt 2>/dev/null)\""
dir="$(cat "$LF_DIRFILE")" dir="$(cat "$LF_DIRFILE")"
rm "$LF_DIRFILE" &>/dev/null rm "$LF_DIRFILE" &>/dev/null
if [ -d "$dir" ]; then while ! cd "$dir"; do
if [ "$dir" != "$(pwd)" ]; then dir="$(dirname -- "$dir")"
cd "$dir" done
fi
fi
reset_prompt reset_prompt
write_title_wd write_title_wd

View file

@ -1,19 +1,11 @@
#!/bin/sh #!/bin/sh
set -e set -e
# clean() { mkdir --parents "${XDG_CACHE_HOME:-"${HOME}/.cache"}/lf"
# exec 3>&-
# rm "$FIFO_UEBERZUG"
# }
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then command lf "$@"
command lf "$@"
else awk '$1 == "archivemount" { print $2 }' /etc/mtab | while read -r mntdir; do
[ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf" sanitized="$(printf "%s" "$mntdir")"
# export FIFO_UEBERZUG="$XDG_RUNTIME_DIR/ueberzug-$$" umount "$sanitized" && rmdir "$sanitized"
# mkfifo "$FIFO_UEBERZUG" done
# ueberzug layer -s -p json <"$FIFO_UEBERZUG" &
# exec 3>"$FIFO_UEBERZUG"
# trap clean EXIT
command lf "$@" 3>&-
fi