summaryrefslogtreecommitdiff
path: root/lf
diff options
context:
space:
mode:
Diffstat (limited to 'lf')
-rw-r--r--lf/lfrc58
-rwxr-xr-xlf/preview.sh47
2 files changed, 102 insertions, 3 deletions
diff --git a/lf/lfrc b/lf/lfrc
index ad4bdb2..40375bd 100644
--- a/lf/lfrc
+++ b/lf/lfrc
@@ -1,4 +1,60 @@
-map . set hidden!
+# map . set hidden!
+set shell sh
+set info size
+set dircounts
+set hidden
+set number
+set relativenumber
+set ratios 1:1:2:3:5
+
+# ranger legacy commands
+map J push 7j
+map K push 7k
+map } half-down
+map { half-up
+map a rename
+
+# execute current file (must be executable)
+map x $$f
+map X !$f
+
+cmd open $nvim $fx # use nvim for files
+
+# git support
+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}}
+
+# fzf support
+cmd fzf ${{
+ res="$(find . | fzf --reverse | sed 's/\\/\\\\/g;s/"/\\"/g')"
+ if [ -d "$res" ] ; then
+ cmd="cd"
+ elif [ -f "$res" ] ; then
+ cmd="select"
+ else
+ exit 0
+ fi
+ lf -remote "send $id $cmd \"$res\""
+}}
+map F fzf
+
+# rg/ripgrep support
+cmd rg ${{
+ res="$( \
+ RG_PREFIX="rg --column --line-number --no-heading --color=always \
+ --smart-case "
+ FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \
+ fzf --reverse --bind "change:reload:$RG_PREFIX {q} || true" \
+ --ansi --layout=reverse --header 'Search in files' \
+ | cut -d':' -f1
+ )"
+ [ ! -z "$res" ] && lf -remote "send $id select \"$res\""
+}}
+map R rg
+
+
+set preview
set previewer ~/.config/lf/preview.sh
map i $~/.config/lf/preview.sh $f | less -RX
diff --git a/lf/preview.sh b/lf/preview.sh
index 46582bf..be52caa 100755
--- a/lf/preview.sh
+++ b/lf/preview.sh
@@ -1,3 +1,46 @@
#!/bin/sh
-unset COLORTERM
-bat --color=always --theme=base16 "$@"
+
+bat --paging=never --style=numbers --terminal-width $(($2-5)) -f "$1"
+
+#
+# unset COLORTERM
+# bat --color=always --theme=base16 "$@"
+
+# MIME=$(mimetype --all --brief "$1")
+#echo "$MIME"
+
+# case "$MIME" in
+# # .pdf
+# *application/pdf*)
+# pdftotext "$1" -
+# ;;
+# # .7z
+# *application/x-7z-compressed*)
+# 7z l "$1"
+# ;;
+# # .tar .tar.Z
+# *application/x-tar*)
+# tar -tvf "$1"
+# ;;
+# # .tar.*
+# *application/x-compressed-tar*|*application/x-*-compressed-tar*)
+# tar -tvf "$1"
+# ;;
+# # .rar
+# *application/vnd.rar*)
+# unrar l "$1"
+# ;;
+# # .zip
+# *application/zip*)
+# unzip -l "$1"
+# ;;
+# # any plain text file that doesn't have a specific handler
+# *text/plain*)
+# # return false to always repaint, in case terminal size changes
+# bat --force-colorization --paging=never --style=changes,numbers \
+# --terminal-width $(($2 - 3)) "$1" && false
+# ;;
+# *)
+# echo "unknown format"
+# ;;
+# esac