dotfiles/.config/zsh/.zshrc

90 lines
2.4 KiB
Bash
Raw 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-07-04 22:52:54 -04:00
# Options
setopt auto_cd
2021-07-03 11:19:37 -04:00
# History
setopt EXTENDED_HISTORY
setopt SHARE_HISTORY
setopt APPEND_HISTORY
2021-07-04 22:52:54 -04:00
# setopt INC_APPEND_HISTORY # unexpected last result with multiple open terminals
2021-07-03 11:19:37 -04:00
setopt HIST_REDUCE_BLANKS
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=$XDG_CACHE_HOME/zshhistory
2021-07-03 11:19:37 -04:00
# Corrections
setopt CORRECT
setopt CORRECT_ALL
# Completion
fpath=($ZDOTDIR/completions $fpath)
autoload -U compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # include hidden files
2021-07-04 22:52:54 -04:00
# Keybindings
bindkey -e # force Emacs state, even with $EDITOR=nvim
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
# edit line in editor w/ ctrl-k (from Luke Smith's .zshrc)
autoload edit-command-line; zle -N edit-command-line
2021-07-03 11:19:37 -04:00
bindkey '^k' edit-command-line
2021-07-04 22:52:54 -04:00
# Aliases
[ -f "$E_SCRIPTS_DIR/aliases.sh" ] && source "$E_SCRIPTS_DIR/aliases.sh"
2021-07-04 22:52:54 -04:00
# 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-07-04 22:52:54 -04:00
# Prompt
PROMPT="%K{238}%F{104}%n%f%k%K{238}%F{104}@%f%k%K{238}%F{104}%m%f%k%K{238}%F{104}:%2~> %f%k"
2021-07-04 22:52:54 -04:00
# Plugins! I try to keep as few as possible
2021-07-29 16:51:49 -04:00
zplugin-git(){
if [[ ! -d ~/.config/zsh/$1 ]]; then
git clone $2 ~/.config/zsh/$1
else
[ -z $UPDATESZ ] || git -C ~/.config/zsh/$1 pull
fi
}
# TODO without starting a new shell in shell
zplugin-git-update(){
UPDATESZ=1 zsh
}
# autocomplete
zplugin-git autocomplete https://github.com/marlonrichert/zsh-autocomplete
source $ZDOTDIR/autocomplete/zsh-autocomplete.plugin.zsh
zstyle ':autocomplete:*' min-input 1
zstyle ':autocomplete:*' min-delay 0.25
2021-07-29 16:51:49 -04:00
# autopair
zplugin-git autopair https://github.com/hlissner/zsh-autopair
source ~/.config/zsh/autopair/autopair.zsh
autopair-init
2021-07-03 11:19:37 -04:00
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
RPROMPT=\$vcs_info_msg_0_
zstyle ':vcs_info:git:*' formats '%F{240}(%b)%r%f'
zstyle ':vcs_info:*' enable git
2021-08-21 20:07:18 -04:00
# Direnv
eval "$(direnv hook zsh)"
# This must be placed at the end
[ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
2021-07-04 22:52:54 -04:00