dotfiles/dot_config/zsh/dot_zshrc.tmpl

73 lines
2.2 KiB
Cheetah

## User-specific Zsh config (on top of what is in /etc/zsh/zshrc)
# turn off Ctrl-D so I don't accidently kill tmux
setopt ignore_eof
## --------------------------------------------------
# autocompletion
## --------------------------------------------------
# ignore full hostnames in ssh config file
# the default ssh function does not seem to differentiate b/t
# HOST and HOSTNAME directives
zstyle ':completion:*:(ssh|scp|rsync|sshfs):*:hosts' ignored-patterns '*.yavin4.ch'
{{- if eq .chezmoi.hostname "petrucci4prez" }}
## --------------------------------------------------
# enable x11 clipboard sync
## --------------------------------------------------
function x11-clip-wrap-widgets() {
# NB: Assume we are the first wrapper and that we only wrap native widgets
# See zsh-autosuggestions.zsh for a more generic and more robust wrapper
local copy_or_paste=$1
shift
for widget in $@; do
if [[ $copy_or_paste == "copy" ]]; then
eval "
function _x11-clip-wrapped-$widget() {
zle .$widget
xclip -in -selection clipboard <<<\$CUTBUFFER
}
"
else
eval "
function _x11-clip-wrapped-$widget() {
CUTBUFFER=\$(xclip -out -selection clipboard)
zle .$widget
}
"
fi
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 paste_widgets=(
vi-put-{before,after}
)
x11-clip-wrap-widgets copy $copy_widgets
x11-clip-wrap-widgets paste $paste_widgets
## --------------------------------------------------
## Python/Ruby Virtual Environments
## --------------------------------------------------
# both of these languages have similar setups for their virtual envs which
# involve a) adding a "shims" directory to PATH and then b) adding some shell
# magic to automatically call the shims
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init - | sed '/PATH/d' -)"
eval "$(pyenv virtualenv-init - | sed '/PATH/d' -)"
fi
if command -v rbenv 1>/dev/null 2>&1; then
eval "$(rbenv init - | sed '/PATH/d' -)"
fi
{{- end }}