diff --git a/common/.config/lf/lfrc b/common/.config/lf/lfrc index 47ccfce1..65221a67 100644 --- a/common/.config/lf/lfrc +++ b/common/.config/lf/lfrc @@ -195,9 +195,15 @@ cmd find_project ${{ }} cmd extract ${{ - for f in $fx; do - aunpack "$f" - done + set -f + ouch decompress $fx +}} + +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 ${{ @@ -262,7 +268,7 @@ map <c-d> confirm_delete map d cut map D &dragon-drop -a -x $fx 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 f find map F find-back @@ -304,8 +310,8 @@ map u :clear; unselect map <c-v> pushedit map v invert # map W new_lf_term -map x $$f -map X !$f +map x :extract +map X :archivemount map <c-y> scroll-down map y copy map Y &echo $f | xclip -r -selection c diff --git a/common/.config/lf/preview b/common/.config/lf/preview index 10883263..ff084bdb 100755 --- a/common/.config/lf/preview +++ b/common/.config/lf/preview @@ -27,12 +27,8 @@ CHAFA="chafa \ --animate false " -archive1() { - 7z l "$f" | sed 1,11d -} - -archive2() { - als -- "$f" +archive() { + ouch list -Htyq "$f" | tail -n +2 } csv() { @@ -46,7 +42,7 @@ docx() { } epub() { - gnome-epub-thumbnailer -s 1024 "$f" /dev/stdout + gnome-epub-thumbnailer -s 1024 "$f" /dev/stdout | $CHAFA } html() { @@ -91,7 +87,7 @@ odt() { } pdf() { - pdftoppm -jpeg -f 1 -singlefile "$f" + pdftoppm -jpeg -f 1 -singlefile "$f" | $CHAFA } sqlite() { @@ -149,7 +145,11 @@ run() { if [ -r "$cache" ]; then cat "$cache" else - "$@" | tee -p "$cache" + if out=$("$@"); then + printf "%s" "$out" | tee -p "$cache" + else + printf "%s" "$out" + fi fi } @@ -158,7 +158,7 @@ preview() { case "$mimetype" in */vnd.openxmlformats-officedocument.spreadsheetml.sheet | */vnd.oasis.opendocument.spreadsheet) run ods ;; */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 ;; image/svg+xml) run -s svg ;; image/*) run -s image ;; @@ -173,7 +173,6 @@ preview() { */msword) run word ;; */x-bittorrent) run torrent ;; */x-cd-image) run iso ;; - */x-bzip-compressed-tar | */x-compressed-tar | */x-xz-compressed-tar) run archive2 ;; */*lua) run lua ;; */*yaml) run yaml ;; *text*) run text ;; diff --git a/common/.config/zsh/config/widgets.zsh b/common/.config/zsh/config/widgets.zsh index 1fb5b976..2781e52b 100644 --- a/common/.config/zsh/config/widgets.zsh +++ b/common/.config/zsh/config/widgets.zsh @@ -79,17 +79,15 @@ zle -N sudo-command-line function lf-wrap() { 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)\"" dir="$(cat "$LF_DIRFILE")" rm "$LF_DIRFILE" &>/dev/null - if [ -d "$dir" ]; then - if [ "$dir" != "$(pwd)" ]; then - cd "$dir" - fi - fi + while ! cd "$dir"; do + dir="$(dirname -- "$dir")" + done reset_prompt write_title_wd diff --git a/common/.local/bin/lfX b/common/.local/bin/lfX index 9084b3d3..b19967a4 100755 --- a/common/.local/bin/lfX +++ b/common/.local/bin/lfX @@ -1,19 +1,11 @@ #!/bin/sh set -e -# clean() { -# exec 3>&- -# rm "$FIFO_UEBERZUG" -# } +mkdir --parents "${XDG_CACHE_HOME:-"${HOME}/.cache"}/lf" -if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - command lf "$@" -else - [ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf" - # export FIFO_UEBERZUG="$XDG_RUNTIME_DIR/ueberzug-$$" - # mkfifo "$FIFO_UEBERZUG" - # ueberzug layer -s -p json <"$FIFO_UEBERZUG" & - # exec 3>"$FIFO_UEBERZUG" - # trap clean EXIT - command lf "$@" 3>&- -fi +command lf "$@" + +awk '$1 == "archivemount" { print $2 }' /etc/mtab | while read -r mntdir; do + sanitized="$(printf "%s" "$mntdir")" + umount "$sanitized" && rmdir "$sanitized" +done