lf cleanup
This commit is contained in:
parent
3e318464aa
commit
6f3900e4f9
|
@ -45,8 +45,6 @@ cmd lazygit %{{
|
||||||
lf -remote "send $id \$cd '$dir' && lazygit"
|
lf -remote "send $id \$cd '$dir' && lazygit"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# y (select for copy) and P to paste soft-link
|
|
||||||
# d (select for cut) and P to paste hard-link
|
|
||||||
cmd link &{{
|
cmd link &{{
|
||||||
set -- $(cat ~/.local/share/lf/files)
|
set -- $(cat ~/.local/share/lf/files)
|
||||||
mode="$1"
|
mode="$1"
|
||||||
|
@ -56,9 +54,7 @@ cmd link &{{
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
# symbolically copy mode is indicating a soft link
|
|
||||||
copy) ln -sr -t . -- "$@";;
|
copy) ln -sr -t . -- "$@";;
|
||||||
# while a move mode is indicating a hard link
|
|
||||||
move) ln -t . -- "$@";;
|
move) ln -t . -- "$@";;
|
||||||
esac
|
esac
|
||||||
rm ~/.local/share/lf/files
|
rm ~/.local/share/lf/files
|
||||||
|
@ -108,8 +104,6 @@ cmd dupe &{{
|
||||||
done
|
done
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c
|
|
||||||
|
|
||||||
cmd fzf ${{
|
cmd fzf ${{
|
||||||
name="$1" input="$2" delimiter="$3" field="$4" path_field="$5" width="$6" query="${7:-}"
|
name="$1" input="$2" delimiter="$3" field="$4" path_field="$5" width="$6" query="${7:-}"
|
||||||
histfile="$XDG_DATA_HOME/lf/$(echo $name | tr '[:upper:]' '[:lower:]')_history"
|
histfile="$XDG_DATA_HOME/lf/$(echo $name | tr '[:upper:]' '[:lower:]')_history"
|
||||||
|
@ -191,8 +185,6 @@ cmd find_project ${{
|
||||||
[ -d "$file" ] && lf -remote "send $id cd $file"
|
[ -d "$file" ] && lf -remote "send $id cd $file"
|
||||||
[ -f "$file" ] && lf -remote "send $id select $file"
|
[ -f "$file" ] && lf -remote "send $id select $file"
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
cmd extract ${{
|
cmd extract ${{
|
||||||
|
@ -201,45 +193,12 @@ cmd extract ${{
|
||||||
done
|
done
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# cmd set_previewer &{{
|
|
||||||
# if [ "${1}" = "sixel" ]; then
|
|
||||||
# lf -remote "send $id :set sixel; set previewer ~/.config/lf/preview/sixel"
|
|
||||||
# # echo 'Previewer set to sixel'
|
|
||||||
# elif [ "${1}" = "ueberzug" ]; then
|
|
||||||
# lf -remote "send $id :set cleaner ~/.config/lf/preview/clean; set previewer ~/.config/lf/preview/ueberzug"
|
|
||||||
# # echo 'Previewer set to ueberzug'
|
|
||||||
# else
|
|
||||||
# lf -remote "send $id :set previewer ~/.config/lf/preview/chafa"
|
|
||||||
# # echo 'Previewer set to chafa'
|
|
||||||
# fi
|
|
||||||
# }}
|
|
||||||
|
|
||||||
# HACK: This is a dirty hack to have an lf terminal that I can "exit" out of into a shell
|
# HACK: This is a dirty hack to have an lf terminal that I can "exit" out of into a shell
|
||||||
cmd new_lf_term &{{
|
cmd new_lf_term &{{
|
||||||
mapcmd='map q $sh -c "tmux; kill $id"'
|
mapcmd='map q $sh -c "tmux; kill $id"'
|
||||||
# previewercmd="set_previewer $(basename "$lf_previewer")"
|
|
||||||
# $TERMINAL -e lfX -command "${previewercmd}; ${mapcmd}"
|
|
||||||
$TERMINAL -e lfX -command "$mapcmd"
|
$TERMINAL -e lfX -command "$mapcmd"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# Setup
|
|
||||||
|
|
||||||
# &{{
|
|
||||||
# set +u
|
|
||||||
# previewer=ueberzug
|
|
||||||
# [ -n "$TMUX" ] && previewer=ueberzug
|
|
||||||
# [ -n "$VIM" ] && previewer=chafa
|
|
||||||
# lf -remote "send $id set_previewer $previewer"
|
|
||||||
#
|
|
||||||
# # Clean up tags that don't exist anymore
|
|
||||||
# # BUG: causes an obscure lf crash when tags are empty
|
|
||||||
# echo "$(
|
|
||||||
# while read -r l; do
|
|
||||||
# file=$(echo "$l" | cut -d ':' -f 1)
|
|
||||||
# [ -e "$file" ] && echo "$l"
|
|
||||||
# done <"${XDG_DATA_HOME}/lf/tags"
|
|
||||||
# )\n" >"${XDG_DATA_HOME}/lf/tags"
|
|
||||||
# }}
|
|
||||||
on-cd
|
on-cd
|
||||||
|
|
||||||
# Basic vars
|
# Basic vars
|
||||||
|
@ -253,7 +212,8 @@ set wrapscroll
|
||||||
set period 1
|
set period 1
|
||||||
set cursorpreviewfmt "\033[7;90m"
|
set cursorpreviewfmt "\033[7;90m"
|
||||||
set promptfmt # this is set in a function later
|
set promptfmt # this is set in a function later
|
||||||
set previewer ~/.config/lf/preview/ueberzug
|
set sixel
|
||||||
|
set previewer ~/.config/lf/preview/preview
|
||||||
set cleaner ~/.config/lf/preview/clean
|
set cleaner ~/.config/lf/preview/clean
|
||||||
|
|
||||||
# Bindings
|
# Bindings
|
||||||
|
@ -263,7 +223,6 @@ map <esc> quit
|
||||||
map <space> :toggle; down
|
map <space> :toggle; down
|
||||||
map <enter> shell
|
map <enter> shell
|
||||||
map <a-enter> shell-wait
|
map <a-enter> shell-wait
|
||||||
# map <tab><tab> fzf 'Shortcuts' 'cat $XDG_DATA_HOME/lf/shortcuts 2>/dev/null' ':' '1' '2' '85%' '^'
|
|
||||||
map <tab><tab> find_project
|
map <tab><tab> find_project
|
||||||
map <tab>t fzf 'Tags' 'cat $XDG_DATA_HOME/lf/tags 2>/dev/null' ':' '1' '1' '50%'
|
map <tab>t fzf 'Tags' 'cat $XDG_DATA_HOME/lf/tags 2>/dev/null' ':' '1' '1' '50%'
|
||||||
map <tab>m fzf 'Marks' 'cat $XDG_DATA_HOME/lf/marks 2>/dev/null' ':' '1' '2' '85%' '^'
|
map <tab>m fzf 'Marks' 'cat $XDG_DATA_HOME/lf/marks 2>/dev/null' ':' '1' '2' '85%' '^'
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
preview
|
|
|
@ -5,27 +5,17 @@ RESET="\033[0m"
|
||||||
|
|
||||||
set -C -f
|
set -C -f
|
||||||
|
|
||||||
f="$(realpath "$1")" w=$2 h=$3 x=$4 y=$5
|
f="$(realpath "$1")" w=$2 h=$3 # x=$4 y=$5
|
||||||
|
|
||||||
image() {
|
image() {
|
||||||
file=${1:-$f}
|
file=${1:-$f}
|
||||||
if [ -f "$file" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||||
name=$(basename "$0")
|
|
||||||
if [ "$name" = "sixel" ]; then
|
|
||||||
[ "$TERM_PROGRAM" = "tmux" ] && tmuxflags="--passthrough tmux"
|
|
||||||
# shellcheck disable=2086
|
|
||||||
echo chafa "$file" -f sixel -s "$((w - 2))x$h" --animate false --polite on $tmuxflags
|
|
||||||
exit 0
|
|
||||||
elif [ "$name" = "ueberzug" ]; then
|
|
||||||
if 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' "$((x + 3))" "$((y + 1))" "$((w - 6))" "$((h - 2))" "$file" >"$FIFO_UEBERZUG"
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
chafa "$file" -s "$((w - 2))x$h" --polite on
|
chafa "$file" -s "$((w - 2))x$h" --polite on
|
||||||
|
else
|
||||||
|
# shellcheck disable=2086
|
||||||
|
chafa -f sixel -s "${w}x${h}" --polite on --animate false "$file"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
video() {
|
video() {
|
||||||
|
@ -103,8 +93,8 @@ if command -v gio 1>/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$(file -b "$f")" in
|
case "$(file -b "$f")" in
|
||||||
*text*) text "$f" ;;
|
*text*) text "$f" ;;
|
||||||
*)
|
*)
|
||||||
printf "%b" "\$(file --mime-type)\t\t\t : $filerun\n"
|
printf "%b" "\$(file --mime-type)\t\t\t : $filerun\n"
|
||||||
[ -n "$giorun" ] && printf "%b" "\$(gio info)\t\t\t\t : $giorun\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"
|
mediainfo "$1" | head -n -2 | grep -v -e "Complete name" -e "General"
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
preview
|
|
|
@ -1 +0,0 @@
|
||||||
preview
|
|
|
@ -1,19 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
clean() {
|
# clean() {
|
||||||
exec 3>&-
|
# exec 3>&-
|
||||||
rm "$FIFO_UEBERZUG"
|
# rm "$FIFO_UEBERZUG"
|
||||||
}
|
# }
|
||||||
|
|
||||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||||
command lf "$@"
|
command lf "$@"
|
||||||
else
|
else
|
||||||
[ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf"
|
[ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf"
|
||||||
export FIFO_UEBERZUG="$XDG_RUNTIME_DIR/ueberzug-$$"
|
# export FIFO_UEBERZUG="$XDG_RUNTIME_DIR/ueberzug-$$"
|
||||||
mkfifo "$FIFO_UEBERZUG"
|
# mkfifo "$FIFO_UEBERZUG"
|
||||||
ueberzug layer -s -p json <"$FIFO_UEBERZUG" &
|
# ueberzug layer -s -p json <"$FIFO_UEBERZUG" &
|
||||||
exec 3>"$FIFO_UEBERZUG"
|
# exec 3>"$FIFO_UEBERZUG"
|
||||||
trap clean EXIT
|
# trap clean EXIT
|
||||||
command lf "$@" 3>&-
|
command lf "$@" 3>&-
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue