From ab7303e1d893f33e09dbc8493f9a9179a7a40a4a Mon Sep 17 00:00:00 2001 From: Mohammad Reza Karimi Date: Thu, 29 Jan 2026 11:40:03 -0500 Subject: updates --- lf/dot-config/lf/lfrc | 21 ++++++++++++--------- lf/dot-config/lf/previewer | 13 +++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100755 lf/dot-config/lf/previewer (limited to 'lf/dot-config') diff --git a/lf/dot-config/lf/lfrc b/lf/dot-config/lf/lfrc index 4d5bd8f..7c367f5 100644 --- a/lf/dot-config/lf/lfrc +++ b/lf/dot-config/lf/lfrc @@ -8,6 +8,7 @@ set icons set scrolloff 10 set period 1 set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" +set previewer "~/.config/lf/previewer" cmd open ${{ case $(file --mime-type "$(readlink -f "$f")" -b) in @@ -31,7 +32,7 @@ cmd extract ${{ while IFS= read -r filename; do filelist+=" $(basename "$filename")" done <<< "$fx" - if ouch decompress "$fx"; then + if safe_extract "$fx"; then lf -remote "send $id echomsg \"Extracted"$filelist" with ouch.\"" else lf -remote "send $id echoerr \"Cannot extract"$filelist" with ouch.\"" @@ -66,11 +67,6 @@ cmd git_branch ${{ lf -remote "send $id updir; cd \"$pwd_shell\"" }} -map gb :git_branch -map gp $clear; git pull --rebase || true; echo "press ENTER"; read ENTER -map gs $clear; git status; echo "press ENTER"; read ENTER -map gl $clear; git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit; echo "press ENTER"; read ENTER - cmd fzf_search ${{ cmd="rg --column --line-number --no-heading --color=always --smart-case" fzf --ansi --disabled --layout=reverse --header="Search in files" --delimiter=: \ @@ -80,8 +76,6 @@ cmd fzf_search ${{ --preview-window='+{2}-/2' \ --preview='bat --color=always --highlight-line={2} -- {1}' }} -map gr :fzf_search - cmd stwify ${{ pkg="$1" @@ -89,12 +83,21 @@ cmd stwify ${{ lf -remote "send $id unselect;" }} +map gb :git_branch +map gp $clear; git pull --rebase || true; echo "press ENTER"; read ENTER +map gs $clear; git status; echo "press ENTER"; read ENTER +map gl $clear; git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit; echo "press ENTER"; read ENTER + +map gr :fzf_search + +map E :extract; reload +map C push :&ouchcompress$fx'' + map S push :stwify"" map Y $printf "%s" "$fx" | wl-copy map push :mkdir"" map D delete map Q quit-and-cd -map E :extract; reload map :fzf_jump map o &mimeopen "$f" map O &mimeopen --ask "$f" diff --git a/lf/dot-config/lf/previewer b/lf/dot-config/lf/previewer new file mode 100755 index 0000000..1ce24f3 --- /dev/null +++ b/lf/dot-config/lf/previewer @@ -0,0 +1,13 @@ +#!/bin/sh + +# Arguments sent to this script: +# (1) current filename, (2) width, (3) height, (4) horizontal position, +# (5) vertical position, and (6) mode ("preview" or "preload") + +case "$(file --dereference --brief --mime-type -- "$1")" in + application/*zip) ouch list "$1";; + */pdf) pdftotext "$1" -;; + text/* | */xml | application/json | application/x-ndjson) bat -p --theme ansi --terminal-width "$(($4-2))" -f "$1";; +esac + +exit 1 -- cgit v1.2.3-71-gdd5e