dotfiles/.config/zsh/.zshrc

79 lines
2.0 KiB
Bash
Raw Permalink Normal View History

# `.zshrc' is sourced in interactive shells. It should contain
# commands to set up aliases, functions, options, key bindings, etc.
autoload -U colors && colors
2021-08-23 15:04:59 -04:00
# Set up the prompt
autoload -Uz promptinit
promptinit
2021-08-23 15:04:59 -04:00
setopt histignorealldups sharehistory
2021-07-03 11:19:37 -04:00
2021-08-23 15:04:59 -04:00
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
2021-07-04 22:52:54 -04:00
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
bindkey -s '^L' '^Uclear^M' # clear using alias
2021-07-04 22:25:42 -04:00
autoload edit-command-line; zle -N edit-command-line
2021-07-03 11:19:37 -04:00
bindkey '^k' edit-command-line
2021-08-23 15:04:59 -04:00
# History
2021-08-23 18:17:11 -04:00
HISTSIZE=9000
SAVEHIST=9000
setopt hist_expire_dups_first
setopt hist_reduce_blanks
setopt hist_ignore_dups
setopt hist_ignore_space
2021-08-23 15:04:59 -04:00
HISTFILE=$XDG_CACHE_HOME/zshhistory
2021-07-04 22:52:54 -04:00
# 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"
2021-07-03 11:19:37 -04:00
2021-08-23 18:17:11 -04:00
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)"