dotfiles/dot_config/zsh/dot_zshrc.tmpl

95 lines
2.7 KiB
Cheetah
Raw Normal View History

## User-specific Zsh config (on top of what is in /etc/zsh/zshrc)
2021-02-15 20:53:16 -05:00
## --------------------------------------------------
# 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'
2021-06-10 23:36:24 -04:00
{{- if eq .chezmoi.hostname "petrucci4prez" }}
2021-02-15 20:53:16 -05:00
## --------------------------------------------------
# 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
2021-02-15 20:53:16 -05:00
## --------------------------------------------------
2021-03-20 14:55:46 -04:00
## Python/Ruby Virtual Environments
2021-02-15 20:53:16 -05:00
## --------------------------------------------------
2021-03-20 14:55:46 -04:00
# 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
zsh-pyenv () {
export PATH=$PYENV_ROOT/shims:$PATH
if command -v pyenv 1>/dev/null 2>&1; then
echo "Activating pyenv"
eval "$(pyenv init - | sed '/PATH/d' -)"
eval "$(pyenv virtualenv-init - | sed '/PATH/d' -)"
else
echo "pyenv not installed"
fi
}
2021-03-20 14:55:46 -04:00
zsh-rbenv () {
gempaths="$(/usr/bin/gem env gempath):"
export PATH="${gempaths//:/\/bin:}:$PATH"
export PATH=$RBENV_ROOT/shims:$PATH
if command -v rbenv 1>/dev/null 2>&1; then
echo "Activating rbenv"
eval "$(rbenv init - | sed '/PATH/d' -)"
else
echo "rbenv not installed"
fi
}
zsh-conda () {
if [[ -x $XDG_DATA_HOME/mambaforge/bin/conda ]]; then
eval "$($XDG_DATA_HOME/mambaforge/bin/conda shell.zsh hook)"
else
echo "conda installation not found"
fi
}
2021-06-12 15:42:06 -04:00
{{- end }}