ENH ensure xclip is installed for clipping function

This commit is contained in:
Nathan Dwarshuis 2022-08-08 22:37:19 -04:00
parent 20b6c93b24
commit c95679e6cf
2 changed files with 38 additions and 36 deletions

View File

@ -34,7 +34,7 @@ pkgs+=(seafile-client)
pkgs+=(rxvt-unicode urxvt-perls) pkgs+=(rxvt-unicode urxvt-perls)
# shell # shell
pkgs+=(zsh zsh-completions) pkgs+=(zsh zsh-completions xclip)
# xmonad # xmonad
mapfile -t xmonad < <("$conf_dir/xmonad/scripts/runtime_pkgs") mapfile -t xmonad < <("$conf_dir/xmonad/scripts/runtime_pkgs")

View File

@ -355,41 +355,43 @@ man() {
## -------------------------------------------------- ## --------------------------------------------------
# enable x11 clipboard sync # enable x11 clipboard sync
## -------------------------------------------------- ## --------------------------------------------------
function x11-clip-wrap-widgets() { if exists xclip; then
# NB: Assume we are the first wrapper and that we only wrap native widgets function x11-clip-wrap-widgets() {
# See zsh-autosuggestions.zsh for a more generic and more robust wrapper # NB: Assume we are the first wrapper and that we only wrap native widgets
local copy_or_paste=$1 # See zsh-autosuggestions.zsh for a more generic and more robust wrapper
shift local copy_or_paste=$1
shift
for widget in $@; do
if [[ $copy_or_paste == "copy" ]]; then for widget in $@; do
eval " if [[ $copy_or_paste == "copy" ]]; then
function _x11-clip-wrapped-$widget() { eval "
zle .$widget function _x11-clip-wrapped-$widget() {
xclip -in -selection clipboard <<<\$CUTBUFFER zle .$widget
} xclip -in -selection clipboard <<<\$CUTBUFFER
" }
else "
eval " else
function _x11-clip-wrapped-$widget() { eval "
CUTBUFFER=\$(xclip -out -selection clipboard) function _x11-clip-wrapped-$widget() {
zle .$widget CUTBUFFER=\$(xclip -out -selection clipboard)
} zle .$widget
" }
fi "
fi
zle -N $widget _x11-clip-wrapped-$widget
done zle -N $widget _x11-clip-wrapped-$widget
} done
}
local copy_widgets=(
vi-yank vi-yank-eol vi-delete vi-backward-kill-word vi-change-whole-line local copy_widgets=(
) vi-yank vi-yank-eol vi-delete vi-backward-kill-word vi-change-whole-line
local paste_widgets=( )
vi-put-{before,after} local paste_widgets=(
) vi-put-{before,after}
x11-clip-wrap-widgets copy $copy_widgets )
x11-clip-wrap-widgets paste $paste_widgets x11-clip-wrap-widgets copy $copy_widgets
x11-clip-wrap-widgets paste $paste_widgets
fi
{{- end }} {{- end }}