new lf preview to reduce dependency on kitty
This commit is contained in:
parent
b583cccc89
commit
947d24ac73
5 changed files with 48 additions and 36 deletions
|
@ -1,2 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
kitty +kitten icat --clear --silent --stdin no --transfer-mode memory >/dev/tty
|
# kitty +kitten icat --clear --silent --stdin no --transfer-mode memory >/dev/tty
|
||||||
|
ueberzugpp cmd -s "$UB_SOCKET" -a remove -i PREVIEW
|
||||||
|
|
|
@ -5,10 +5,11 @@ image() {
|
||||||
h=$3
|
h=$3
|
||||||
x=$4
|
x=$4
|
||||||
y=$5
|
y=$5
|
||||||
kitty +kitten icat --clear --stdin no --silent --transfer-mode memory --place "${w}x${h}@${x}x${y}" "$f" >/dev/tty && exit 1
|
# kitty +kitten icat --clear --stdin no --silent --transfer-mode memory --place "${w}x${h}@${x}x${y}" "$f" >/dev/tty && exit 1
|
||||||
chafa "$f" -f symbols -s "$((w-2))x$h" && exit 1
|
# chafa "$f" -f symbols -s "$((w-2))x$h" && exit 1
|
||||||
printf "%b" "\033[31mImage previewer failed\033[0m"
|
ueberzugpp cmd -s "$UB_SOCKET" -a add -i PREVIEW -x "$x" -y "$y" --max-width $(($2-1)) --max-height "$h" -f "$f" && exit 1
|
||||||
return 1
|
printf "%b" "\033[31mImage previewer failed\033[0m\n"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
video() {
|
video() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ bindkey -M menuselect 'l' vi-forward-char
|
||||||
bindkey -M menuselect 'j' vi-down-line-or-history
|
bindkey -M menuselect 'j' vi-down-line-or-history
|
||||||
|
|
||||||
# Widgets
|
# Widgets
|
||||||
bindkey '^e' _lfcd
|
bindkey '^e' _lf
|
||||||
bindkey '^g' lg
|
bindkey '^g' lg
|
||||||
bindkey -M vicmd v edit-command-line
|
bindkey -M vicmd v edit-command-line
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,45 @@
|
||||||
# vim:set ft=zsh
|
# vim:set ft=zsh
|
||||||
# LF Change Dir
|
|
||||||
function lfcd () {
|
function lfclean () {
|
||||||
tmp="$(mktemp)"
|
exec 3>&-
|
||||||
fid="$(mktemp)"
|
ueberzugpp cmd -s $UB_SOCKET -a exit
|
||||||
lf -command '$printf $id > '"$fid"'' -last-dir-path="$tmp" "$@"
|
dir="$(cat "$lftmp")"
|
||||||
id="$(cat "$fid")"
|
rm "$lftmp"
|
||||||
archivemount_dir="/tmp/__lf_archivemount_$id"
|
if [ -d "$dir" ]; then
|
||||||
if [ -f "$archivemount_dir" ]; then
|
if [ "$dir" != "$(pwd)" ]; then
|
||||||
cat "$archivemount_dir" | \
|
cd "$dir"
|
||||||
while read -r line; do
|
|
||||||
sudo umount "$line"
|
|
||||||
rmdir "$line"
|
|
||||||
done
|
|
||||||
command rm -f "$archivemount_dir"
|
|
||||||
fi
|
|
||||||
if [ -f "$tmp" ]; then
|
|
||||||
dir="$(cat "$tmp")"
|
|
||||||
command rm -f "$tmp"
|
|
||||||
if [ -d "$dir" ]; then
|
|
||||||
if [ "$dir" != "$(pwd)" ]; then
|
|
||||||
cd "$dir"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# LF wrapper to allow for ueberzug previews
|
||||||
|
function lfwrap () {
|
||||||
|
UB_PID=0
|
||||||
|
UB_SOCKET=""
|
||||||
|
lftmp="/tmp/lfdir.$(uuidgen)"
|
||||||
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||||
|
command lf -last-dir-path="$lftmp" "$@"
|
||||||
|
else
|
||||||
|
[ ! -d "$XDG_CACHE_HOME/lf" ] && mkdir --parents "$XDG_CACHE_HOME/lf"
|
||||||
|
ubtmp="/tmp/ubpid.$(uuidgen)"
|
||||||
|
{
|
||||||
|
ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$ubtmp"
|
||||||
|
UB_PID=$(cat "$ubtmp")
|
||||||
|
rm "$ubtmp"
|
||||||
|
UB_SOCKET="/tmp/ueberzugpp-${UB_PID}.socket"
|
||||||
|
export UB_PID UB_SOCKET
|
||||||
|
}
|
||||||
|
trap lfclean HUP INT QUIT TERM PWR EXIT
|
||||||
|
command lf -last-dir-path="$lftmp" "$@" 3>&-
|
||||||
|
fi
|
||||||
tput cuu1;tput el
|
tput cuu1;tput el
|
||||||
}
|
}
|
||||||
function _lfcd () {
|
|
||||||
BUFFER="lfcd"
|
function _lf () {
|
||||||
zle accept-line
|
BUFFER="lfwrap"
|
||||||
|
zle accept-line
|
||||||
}
|
}
|
||||||
zle -N _lfcd
|
zle -N _lf
|
||||||
|
|
||||||
# Cursor Shape
|
# Cursor Shape
|
||||||
function zle-keymap-select () {
|
function zle-keymap-select () {
|
||||||
|
@ -50,9 +60,8 @@ zle -N edit-command-line
|
||||||
|
|
||||||
# Lazygit
|
# Lazygit
|
||||||
function lg () {
|
function lg () {
|
||||||
[ ! -d "$(pwd)/.git" ] && [[ $(read -ek "?Not in a git repository. Create a new git repository? (y/n): ") =~ ^[Yy]$ ]] && git init
|
[ ! -d "$(pwd)/.git" ] && [[ $(read -erk "?Not in a git repository. Create a new git repository? (y/n): ") =~ ^[Yy]$ ]] && git init
|
||||||
[ -d "$(pwd)/.git" ] && lazygit -p $(pwd)
|
[ -d "$(pwd)/.git" ] && lazygit -p "$(pwd)"
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N lg{,}
|
zle -N lg{,}
|
||||||
|
|
||||||
|
|
1
TODO.md
1
TODO.md
|
@ -3,6 +3,7 @@
|
||||||
- [ ] Remove username from ssh completion
|
- [ ] Remove username from ssh completion
|
||||||
- [ ] add a messaging function to dotsync to warn for breaking changes
|
- [ ] add a messaging function to dotsync to warn for breaking changes
|
||||||
- [ ] check font names for void, adjust fontconfig
|
- [ ] check font names for void, adjust fontconfig
|
||||||
|
- [ ] async ueberzugpp startup
|
||||||
|
|
||||||
# FIX
|
# FIX
|
||||||
- [ ] sb-playerctl trailing dash when no artist
|
- [ ] sb-playerctl trailing dash when no artist
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue