dotfiles/.config/zsh/.zshrc

80 lines
2.1 KiB
Bash

# `.zshrc' is sourced in interactive shells. It should contain
# commands to set up aliases, functions, options, key bindings, etc.
autoload -U colors && colors
# Set up the prompt
autoload -Uz promptinit
promptinit
setopt histignorealldups sharehistory
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
bindkey -s '^L' '^Uclear^M' # clear using alias
autoload edit-command-line; zle -N edit-command-line
bindkey '^k' edit-command-line
# History
HISTSIZE=9000
SAVEHIST=9000
setopt extended_history
setopt hist_expire_dups_first
setopt hist_reduce_blanks
setopt hist_ignore_dups
setopt hist_ignore_space
HISTFILE=$XDG_CACHE_HOME/zshhistory
# Aliases
[ -f "$E_SCRIPTS_DIR/aliases.sh" ] && source "$E_SCRIPTS_DIR/aliases.sh"
# zsh-specific aliases
# clear zsh history: Adapted from Novimatrem: https://gitlab.com/Novimatrem/clear-bash-history
alias czh="echo 'Fully clearing history, then exiting...' && cat /dev/null > $XDG_CACHE_HOME/zshhistory && history -p && exit"
fpath=($ZDOTDIR/completions $fpath)
_comp_options+=(globdots) # include hidden files
# reload the zsh session. From OMZ:plugins/zsh_reload
zreload() {
local cache="$ZSH_CACHE_DIR"
autoload -U compinit zrecompile
compinit -i -d "$cache/zcomp-$HOST"
for f in ${ZDOTDIR:-~}/.zshrc "$cache/zcomp-$HOST"; do
zrecompile -p $f && command rm -f $f.zwc.old
done
# Use $SHELL if available; remove leading dash if login shell
[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
}
# Plugin management
[[ -f $ZDOTDIR/znap/znap.zsh ]] ||
git clone https://github.com/marlonrichert/zsh-snap $ZDOTDIR/znap
source $ZDOTDIR/znap/znap.zsh
znap source marlonrichert/zsh-autocomplete
zstyle ':autocomplete:*' min-input 1
zstyle ':autocomplete:*' min-delay 0.25
znap source hlissner/zsh-autopair
znap source zsh-users/zsh-syntax-highlighting
PURE_PROMPT_SYMBOL=
znap prompt sindresorhus/pure
zstyle :prompt:pure:git:stash show yes
znap source MichaelAquilina/zsh-you-should-use
# auto cd must be set later
setopt AUTO_CD
# Hooks
eval "$(direnv hook zsh)"