separate lf wrapper from zsh config
This commit is contained in:
parent
947d24ac73
commit
3f8af175cb
|
@ -9,7 +9,7 @@ bindkey -M menuselect 'l' vi-forward-char
|
|||
bindkey -M menuselect 'j' vi-down-line-or-history
|
||||
|
||||
# Widgets
|
||||
bindkey '^e' _lf
|
||||
bindkey '^e' _lfwrap
|
||||
bindkey '^g' lg
|
||||
bindkey -M vicmd v edit-command-line
|
||||
|
||||
|
|
|
@ -1,45 +1,10 @@
|
|||
# vim:set ft=zsh
|
||||
|
||||
function lfclean () {
|
||||
exec 3>&-
|
||||
ueberzugpp cmd -s $UB_SOCKET -a exit
|
||||
dir="$(cat "$lftmp")"
|
||||
rm "$lftmp"
|
||||
if [ -d "$dir" ]; then
|
||||
if [ "$dir" != "$(pwd)" ]; then
|
||||
cd "$dir"
|
||||
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
|
||||
}
|
||||
|
||||
function _lf () {
|
||||
function _lfwrap () {
|
||||
BUFFER="lfwrap"
|
||||
zle accept-line
|
||||
}
|
||||
zle -N _lf
|
||||
zle -N _lfwrap
|
||||
|
||||
# Cursor Shape
|
||||
function zle-keymap-select () {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
UB_PID=0
|
||||
UB_SOCKET=""
|
||||
LF_DIRFILE="/tmp/lfdir.$(uuidgen)"
|
||||
UB_PIDFILE="/tmp/ubpid.$(uuidgen)"
|
||||
|
||||
clean () {
|
||||
exec 3>&-
|
||||
ueberzugpp cmd -s "$UB_SOCKET" -a exit
|
||||
}
|
||||
|
||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||
command lf -last-dir-path="$LF_DIRFILE" "$@"
|
||||
else
|
||||
[ ! -d "$XDG_CACHE_HOME/lf" ] && mkdir --parents "$XDG_CACHE_HOME/lf"
|
||||
ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PIDFILE"
|
||||
UB_PID=$(cat "$UB_PIDFILE")
|
||||
UB_SOCKET="/tmp/ueberzugpp-${UB_PID}.socket"
|
||||
rm "$UB_PIDFILE"
|
||||
export UB_PID UB_SOCKET
|
||||
trap clean HUP INT QUIT TERM PWR EXIT
|
||||
command lf -last-dir-path="$LF_DIRFILE" "$@" 3>&-
|
||||
fi
|
||||
|
||||
dir="$(cat "$LF_DIRFILE")"
|
||||
rm "$LF_DIRFILE"
|
||||
if [ -d "$dir" ]; then
|
||||
if [ "$dir" != "$(pwd)" ]; then
|
||||
cd "$dir"
|
||||
fi
|
||||
fi
|
||||
tput cuu1;tput el
|
Loading…
Reference in New Issue