aboutsummaryrefslogtreecommitdiff
path: root/lf/dot-config
diff options
context:
space:
mode:
Diffstat (limited to 'lf/dot-config')
-rw-r--r--lf/dot-config/lf/lfrc21
-rwxr-xr-xlf/dot-config/lf/previewer13
2 files changed, 25 insertions, 9 deletions
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 :&ouch<space>compress<space>$fx<space>''<left>
+
map S push :stwify<space>""<left>
map Y $printf "%s" "$fx" | wl-copy
map <c-n> push :mkdir<space>""<left>
map D delete
map Q quit-and-cd
-map E :extract; reload
map <c-f> :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