;;
/dev/pts/[0-9]*)
alias l1='EZA_GRID_ROWS=26 eza -w 0 --group --group-directories-first -1'
- alias la='EZA_GRID_ROWS=26 eza -w 55 --group --group-directories-first --icons -l -a'
- alias lg='EZA_GRID_ROWS=26 eza -w 0 --group --long --grid --group-directories-first'
- alias ll='EZA_GRID_ROWS=26 eza -w 55 --group --group-directories-first --icons -l'
- alias ls='EZA_GRID_ROWS=26 eza -w 55 --group --group-directories-first --icons'
- alias lt='EZA_GRID_ROWS=26 eza -w 0 --group --long --grid --group-directories-first --sort=mod -t=mod --time-style=long-iso'
+ alias la='EZA_GRID_ROWS=26 eza -w 55 --group --group-directories-first --icons -l -a --hyperlink'
+ alias lg='EZA_GRID_ROWS=26 eza -w 0 --group --long --grid --group-directories-first --hyperlink'
+ alias ll='EZA_GRID_ROWS=26 eza -w 55 --group --group-directories-first --icons -l --hyperlink'
+ alias ls='EZA_GRID_ROWS=26 eza -w 55 --group --group-directories-first --icons --hyperlink'
+ alias lt='EZA_GRID_ROWS=26 eza -w 0 --group --long --grid --group-directories-first --sort=mod -t=mod --time-style=long-iso --hyperlink'
;;
esac
--- /dev/null
+set chafasixel
+
+++ /dev/null
-function lf --wraps=lfrun --description 'alias lf=lfrun'
- lfrun $argv
-
-end
set icons
set info size
set sortby name
+set drawbox true
+set roundbox true
-set previewer ~/.config/lf/scripts/preview
-set cleaner ~/.config/lf/scripts/cleaner
+# previews via ueberzugpp and wrapper
+# set previewer ~/.config/lf/scripts/preview
+# set cleaner ~/.config/lf/scripts/cleaner
+
+# previews via https://github.com/NikitaIvanovV/ctpv?tab=readme-ov-file
+set sixel true
+set previewer ctpv
+set cleaner ctpvclear
+&ctpv -s $id
+&ctpvquit $id
# interpreter for shell commands
set shell sh
set scrolloff 3
# use enter for shell commands
-# map <enter> shell
-
-# execute current file (must be executable)
-# map x $$f
-# map X !$f
-
-# dedicated keys for file opener actions
-# map o &mimeopen $f
-# map O $mimeopen --ask $f
-
-# mkdir command. See wiki if you want it to select created dir
-# map a :push %mkdir<space>
+map <enter> shell
# make sure trash folder exists
%mkdir -p ~/.trash
touch $ans
}}
+cmd add-file-and-edit %{{
+ IFS=" "
+ file="$*"
+ touch -- "$file"
+ file="$(printf '%s' "$file" | sed 's/\\/\\\\/g;s/"/\\"/g')"
+ lf -remote "send $id :select \"$file\"; \$\$EDITOR \"$file\""
+}}
+
# set terminal title to current working directory
cmd on-cd &{{
printf "\033]0; $PWD\007" > /dev/tty
lf -remote "send $id set statfmt \"$(eza -ldo --color=always --smart-group --no-permissions "$f")\""
}}
+cmd goto-file &{{
+ if [ -n "$(find -mindepth 1 -maxdepth 1 -type d -print -quit)" ]; then
+ lf -remote "send $id :set dironly; bottom; set nodironly; down"
+ else
+ lf -remote "send $id top"
+ fi
+}}
+
cmd fzf_jump ${{
res="$(find . -maxdepth 1 | fzf --reverse --header='Jump to location')"
if [ -n "$res" ]; then
setlocal /mnt sortby name
# unmap keys
+map G
map c
map d
map m
map p
+map r
+map sa
+map sc
+map sd
+map se
+map sf
+map sn
+map ss
+map st
map t
map x
-# map u is unselect
+map u is unselect
# m = mark
# a = add/apply
map ad add-dir
+map ae add-file-and-edit
map aD add-dir-and-move-selection
map af add-file
map aw :apply-wallpaper
map dZ delete #zap
# g = goto
-map ga cd ~/Applications/
-map gc cd ~/.config
+map GM cd /mnt
+map Ga cd ~/Applications/
+map Gc cd ~/.config
+map Gd cd ~/dotfiles/
+map Gl cd ~/.local
+map Gm cd /media
+map Gs cd ~/Bilder/Screenshots
+map Gt cd ~/.local/share/Trash/
+map Gw cd ~/Bilder/Wallpapers
map gd cd ~/Downloads/
-map gD cd ~/dotfiles/
-map gf :fzf_search
-map gl cd ~/.local
-map gL follow-link
-map gm cd /media
-map gM cd /mnt
map ge bottom
-map gs cd ~/Bilder/Screenshots
+map gf :fzf_search
+map gf goto-file
+map gl follow-link
map go :fzf_jump
-map gt cd ~/.local/share/Trash/
-map gw cd ~/Bilder/Wallpapers
# o = order
map oC : set sortby ctime; set reverse true; set info ctime
map ot : set sortby time; set reverse true; set info time
# p = paste
-map pp :paste; clear
-map pP :paste
-map pl :link; clear
-map pL :link
+map pL :link; clear
+map pP :paste; clear
+map pl :link
+map pp :paste
# q =
map q
map Q : quit
+# r = rename
+map rb bulk-rename
+map rr rename
+map rh :rename; cmd-home
+map rl :rename; cmd-end
+map rf :rename; cmd-delete-home
+map rA :rename; cmd-end; cmd-delete-home
+
# s = select
map sd select-dirs
map sf select-files
+map s+ push :glob-select<space>
+map s- push :glob-unselect<space>
+map si invert
+map su unselect
# x = extract/execute
map xe extract
map xt open-cwd-in-terminal
map xg push :open-with-gui<space>
-map xt push :open-with-cli<space>
+map xc push :open-with-cli<space>
+map xx &mimeopen $f
+map xo $mimeopen --ask $f
+map xs $$f
+map xa !$f
+
+# z = ???
+zp = set info perm:user:group
# one-shot commands
map R bulk-rename
map <esc> unselect
map ~ toggle_preview
map C edit-config
-map + push :glob-select<space>
-map - push :glob-unselect<space>
-# map <enter> push :open-with-gui<space>
-# map <a-enter> push :open-with-cli<space>
map <c-f> $lf -remote "send $id select '$(fzf)'"
+++ /dev/null
-#!/bin/sh
-
-ueberzugpp cmd -s $UB_SOCKET -a remove -i PREVIEW
+++ /dev/null
-#!/bin/sh
-
-# This is a wrapper script for lf that allows it to create image previews with
-# ueberzug. This works in concert with the lf configuration file and the
-# lf-cleaner script.
-
-set -e
-
-UB_PID=0
-UB_SOCKET=""
-
-case "$(uname -a)" in
- *Darwin*) UEBERZUG_TMP_DIR="$TMPDIR" ;;
- *) UEBERZUG_TMP_DIR="/tmp" ;;
-esac
-
-cleanup() {
- exec 3>&-
- ueberzugpp cmd -s "$UB_SOCKET" -a exit
-}
-
-if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
- lf "$@"
-else
- [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
- UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)"
- ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE"
- UB_PID=$(cat "$UB_PID_FILE")
- rm "$UB_PID_FILE"
- UB_SOCKET="$UEBERZUG_TMP_DIR/ueberzugpp-${UB_PID}.socket"
- export UB_PID UB_SOCKET
- trap cleanup HUP INT QUIT TERM EXIT
- lf "$@" 3>&-
-fi
+++ /dev/null
-#!/bin/sh
-
-image() {
- FILE_PATH="$1"
- X=$4
- Y=$5
- MW=$(($2 - 1))
- MH=$3
- ueberzugpp cmd -s "$UB_SOCKET" -a add -i PREVIEW -x "$X" -y "$Y" --max-width "$MW" --max-height "$MH" -f "$FILE_PATH"
- exit 1
-}
-
-batorcat() {
- file="$1"
- shift
- if command -v bat >/dev/null 2>&1; then
- bat --color=always --style=plain --pager=never "$file" "$@"
- else
- cat "$file"
- fi
-}
-
-CACHE="$HOME/.cache/lf/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}'))"
-
-case "$(printf "%s\n" "$(readlink -f "$1")" | tr '[:upper:]' '[:lower:]')" in
- *.tgz | *.tar.gz) tar tzf "$1" ;;
- *.tar.bz2 | *.tbz2) tar tjf "$1" ;;
- *.tar.txz | *.txz) xz --list "$1" ;;
- *.tar) tar tf "$1" ;;
- *.zip | *.jar | *.war | *.ear | *.oxt) unzip -l "$1" ;;
- *.rar) unrar l "$1" ;;
- *.7z) 7z l "$1" ;;
- *.[1-8]) man "$1" | col -b ;;
- *.o) nm "$1" ;;
- *.torrent) transmission-show "$1" ;;
- *.iso) iso-info --no-header -l "$1" ;;
- *.odt | *.ods | *.odp | *.sxw) odt2txt "$1" ;;
- *.doc) catdoc "$1" ;;
- *.docx) docx2txt "$1" - ;;
- *.xls | *.xlsx)
- ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batorcat --language=csv
- ;;
- *.wav | *.mp3 | *.flac | *.m4a | *.wma | *.ape | *.ac3 | *.og[agx] | *.spx | *.opus | *.as[fx] | *.mka)
- exiftool "$1"
- ;;
- *.pdf)
- [ ! -f "${CACHE}.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
- image "${CACHE}.jpg" "$2" "$3" "$4" "$5"
- ;;
- *.avi | *.mp4 | *.wmv | *.dat | *.3gp | *.ogv | *.mkv | *.mpg | *.mpeg | *.vob | *.fl[icv] | *.m2v | *.mov | *.webm | *.ts | *.mts | *.m4v | *.r[am] | *.qt | *.divx)
- [ ! -f "${CACHE}.jpg" ] && ffmpegthumbnailer -i "$1" -o "${CACHE}.jpg" -s 0 -q 5
- image "${CACHE}.jpg" "$2" "$3" "$4" "$5"
- ;;
- *.bmp | *.jpg | *.jpeg | *.png | *.xpm | *.webp | *.gif | *.jfif)
- image "$1" "$2" "$3" "$4" "$5"
- ;;
- *.svg)
- [ ! -f "${CACHE}.jpg" ] && convert "$1" "${CACHE}.jpg"
- image "${CACHE}.jpg" "$2" "$3" "$4" "$5"
- ;;
- *)
- batorcat "$1"
- ;;
-esac
-exit 0
+++ /dev/null
-!/bin/bash
-## ~/.config/lf/previewer_sandbox
-
-set -euo pipefail
-(
- exec bwrap \
- --ro-bind /usr/bin /usr/bin \
- --ro-bind /usr/share/ /usr/share/ \
- --ro-bind /usr/lib /usr/lib \
- --ro-bind /usr/lib64 /usr/lib64 \
- --symlink /usr/bin /bin \
- --symlink /usr/bin /sbin \
- --symlink /usr/lib /lib \
- --symlink /usr/lib64 /lib64 \
- --proc /proc \
- --dev /dev \
- --ro-bind /etc /etc \
- --ro-bind ~/.config ~/.config \
- --ro-bind ~/.cache ~/.cache \
- --ro-bind "$PWD" "$PWD" \
- --unshare-all \
- --new-session \
- bash ~/.config/lf/preview "$@"
-)
-
# ueberzug. This works in concert with the lf configuration file and the
# lf-cleaner script.
-set -e
+set -euf
-BROWSER="$(printf "qutebrowser\n--untrusted-args\n")"
-EDITOR="$(printf "kks\nedit\n")"
-VISUAL="$(printf "kks\nedit\n")"
-# PAGER="$(printf "bat\n--style\nauto\n--pager\nalways\n")"
+if [ -n "${DISPLAY-}" ] && [ -z "${FIFO_UEBERZUG-}" ]; then
+ export FIFO_UEBERZUG="${TMPDIR:-/tmp}/lf-ueberzug-$$"
-
-UB_PID=0
-UB_SOCKET=""
-
-case "$(uname -a)" in
- *Darwin*) UEBERZUG_TMP_DIR="$TMPDIR" ;;
- *) UEBERZUG_TMP_DIR="/tmp" ;;
-esac
-
-cleanup() {
+ cleanup() {
exec 3>&-
- ueberzugpp cmd -s "$UB_SOCKET" -a exit
-}
-
-if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
- lf "$@"
+ rm -- "$FIFO_UEBERZUG"
+ }
+
+ mkfifo -- "$FIFO_UEBERZUG"
+ # Execute ueberzug in a loop in case it crashes. Ueberzug dies if its
+ # associated window is closed. This breaks image previews when using tmux and
+ # reattaching to an existing session.
+ while [ -p "$FIFO_UEBERZUG" ] && ! ueberzug layer -s <"$FIFO_UEBERZUG"; do :; done &
+ # Open the FIFO for writing. FIFO readers receive an EOF once all writers
+ # have closed their respective file descriptors. Holding a file descriptor
+ # will effectively keep ueberzug alive as long as lf lives.
+ exec 3>"$FIFO_UEBERZUG"
+ trap cleanup EXIT
+
+ # Start lf without passing in the file descriptor. This is done to avoid the
+ # lf server being passed the file descriptor, which would cause ueberzug to
+ # live longer than is strictly necessary.
+ lf "$@" 3>&-
else
- [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
- UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)"
- ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE"
- UB_PID=$(cat "$UB_PID_FILE")
- rm "$UB_PID_FILE"
- UB_SOCKET="$UEBERZUG_TMP_DIR/ueberzugpp-${UB_PID}.socket"
- export UB_PID UB_SOCKET
- trap cleanup HUP INT QUIT TERM EXIT
- lf "$@" 3>&-
+ exec lf "$@"
fi
-