lf improvements
This commit is contained in:
parent
9c3078a4bc
commit
0a2f9b2332
4 changed files with 33 additions and 18 deletions
|
@ -142,6 +142,11 @@ cmd fzfgrep ${{
|
|||
)"
|
||||
[ -n "$res" ] && lf -remote "send $id select \"$res\""
|
||||
}}
|
||||
cmd extract ${{
|
||||
for f in $fx; do
|
||||
aunpack "$f"
|
||||
done
|
||||
}}
|
||||
|
||||
# cmd fzfworkon ${{
|
||||
# workon -n $(workon | fzf)
|
||||
|
@ -156,7 +161,7 @@ map <c-c>g fzfgrep
|
|||
map T trash
|
||||
map <c-t> $trash-restore $PWD
|
||||
map <c-d> &rm -rf -- $fx
|
||||
map <c-e> $aunpack $fx
|
||||
map <c-e> extract
|
||||
map R toggle-preview
|
||||
map P link
|
||||
# map S share
|
||||
|
|
|
@ -17,6 +17,8 @@ image() {
|
|||
h=$3
|
||||
x=$4
|
||||
y=$5
|
||||
# TODO: Maybe append some mediainfo output into the image with ffmpeg (when there's enough space)
|
||||
# I assume that will take a bit of math that I'll try to implement in perl or python
|
||||
if [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; then
|
||||
printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$(($4 + 3))" "$(($5 + 1))" "$(($2 - 6))" "$(($3 - 2))" "$1" >"$FIFO_UEBERZUG"
|
||||
fi
|
||||
|
@ -36,13 +38,11 @@ video() {
|
|||
image "$thumb" "$w" "$h" "$x" "$y"
|
||||
}
|
||||
|
||||
batorcat() {
|
||||
text() {
|
||||
f=$1
|
||||
w=$2
|
||||
command -v bat >/dev/null 2>&1 && bat --color=always --style=plain --pager=never --terminal-width "$((w - 2))" "$f" && exit 0
|
||||
command -v batcat >/dev/null 2>&1 && batcat --color=always --style=plain --pager=never --terminal-width "$((w - 2))" "$f" && exit 0
|
||||
cat "$f"
|
||||
exit 0
|
||||
bat --color=always --style=plain --pager=never --terminal-width "$((w - 2))" "$f" && exit 1
|
||||
cat "$f"; exit 1
|
||||
}
|
||||
|
||||
run() {
|
||||
|
@ -51,7 +51,7 @@ run() {
|
|||
printf "%b" "${RED}Cannot execute $1${RESET}"
|
||||
exit 1
|
||||
elif $@; then
|
||||
exit 0
|
||||
exit 1
|
||||
else
|
||||
printf "%b" "${RED}Failed to run command: $*${RESET}"
|
||||
exit 1
|
||||
|
@ -60,7 +60,7 @@ run() {
|
|||
|
||||
mimetest() {
|
||||
case "$1" in
|
||||
text/*) batorcat "$f" "$w" ;;
|
||||
text/*) text "$f" "$w" ;;
|
||||
*/pdf)
|
||||
[ ! -f "${CACHE}.jpg" ] && run pdftoppm -jpeg -f 1 -singlefile "$f" "$CACHE"
|
||||
image "${CACHE}.jpg" "$w" "$h" "$x" "$y"
|
||||
|
@ -72,8 +72,8 @@ mimetest() {
|
|||
*/vnd.sun.xml.writer) run odt2txt "$f" ;;
|
||||
*/msword) run catdoc "$f" ;;
|
||||
*/vnd.openxmlformats-officedocument.wordprocessingml.document) run docx2txt <"$f" ;;
|
||||
*/vnd.ms-excel) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | batorcat --language=csv ;;
|
||||
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | batorcat --language=csv ;;
|
||||
*/vnd.ms-excel) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv ;;
|
||||
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv ;;
|
||||
*/epub+zip)
|
||||
[ ! -f "$CACHE" ] && run epub-thumbnailer "$f" "$CACHE" 1024
|
||||
image "$CACHE" "$w" "$h" "$x" "$y"
|
||||
|
@ -94,13 +94,22 @@ mimetest() {
|
|||
}
|
||||
|
||||
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 $(file -b "$f") in
|
||||
*ascii* | *utf*) batorcat "$f" "$w";;
|
||||
esac
|
||||
mimetest "$(env XDG_CURRENT_DESKTOP=GNOME xdg-mime query filetype "$f")" && exit
|
||||
mimetest "$(xdg-mime query filetype "$f")" && exit 0
|
||||
|
||||
env XDG_CURRENT_DESKTOP=GNOME xdg-mime query filetype "$1"
|
||||
mediainfo "$1"
|
||||
filerun="$(file --brief --dereference --mime-type "$f")"
|
||||
mimetest "$filerun" && exit 1
|
||||
|
||||
if command -v gio 1>/dev/null 2>&1; then
|
||||
giorun="$(gio info "$f" 2>/dev/null | grep standard::content-type | cut -d' ' -f4)"
|
||||
mimetest "$giorun" && exit 1
|
||||
fi
|
||||
|
||||
printf "%b" "\$(file --mime-type)\t\t\t : $filerun\n"
|
||||
[ -n "$giorun" ] && printf "%b" "\$(gio info)\t\t\t\t : $giorun\n"
|
||||
|
||||
mediainfo "$1" | head -n-2 | grep -v -e "Complete name" -e "General"
|
||||
|
||||
case $(file -b "$f") in
|
||||
*ascii* | *utf*) text "$f" "$w";;
|
||||
esac
|
||||
|
||||
exit 1
|
||||
|
|
|
@ -87,7 +87,7 @@ mime ^audio|ogg$, terminal, has mpv ,flag t = mpv -- "$@"
|
|||
#-------------------------------------------
|
||||
mime ^video, has mpv, X, flag f = mpv --save-position-on-quit -- "$@"
|
||||
ext ts, has mpv, X, flag f = mpv --save-position-on-quit -- "$@"
|
||||
mime ^video, has mpv, X, flag f = mpv -- "$@"
|
||||
mime ^video, has mpv, X, flag f = vlc -- "$@"
|
||||
|
||||
#--------------------------------------------
|
||||
# Video without X:
|
||||
|
|
1
.config/lf/todo
Normal file
1
.config/lf/todo
Normal file
|
@ -0,0 +1 @@
|
|||
gpg asks for unlock when viewing gpg keys
|
Loading…
Add table
Reference in a new issue