dotfiles/.zshrc
2025-05-05 06:58:49 +02:00

113 lines
3.2 KiB
Bash

zstyle :compinstall filename '/home/patrick/.zshrc'
fpath+=~/.zfunc
autoload -Uz promptinit && promptinit
autoload -Uz compinit && compinit
autoload -Uz colors && colors
autoload -Uz bashcompinit && bashcompinit
zmodload -i zsh/complist
zstyle ':completion:*' accept-exact "*(N)"
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/compcache
# Fix keyboard
bindkey -v # Vi bindings
export KEYTIMEOUT=1 # Reduce esc timeout
if [[ "${terminfo[khome]}" != "" ]]; then
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
fi
if [[ "${terminfo[kend]}" != "" ]]; then
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
fi
bindkey ' ' magic-space # [Space] - do history expansion
if [[ "${terminfo[kcbt]}" != "" ]]; then
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
fi
bindkey '^?' backward-delete-char # [Backspace] - delete backward
if [[ "${terminfo[kdch1]}" != "" ]]; then
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
else
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
fi
bindkey '^R' history-incremental-search-backward # Reverse history search
# Autocomplete menu
bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu select
# Case insensitive autocomplete
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
# disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
# Loading dots for autocomplete
expand-or-complete-with-dots() {
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey '^I' expand-or-complete-with-dots
# Starship!
eval "$(starship init zsh)"
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=1000
setopt extendedglob
setopt histignoredups
if [ -f ~/.zshrc.local ]; then
source ~/.zshrc.local
fi
# Dotfiles management
alias dotfiles='git --work-tree=$HOME --git-dir=$HOME/.dotfiles.git'
# SSH Agent using Keychain
eval $(keychain --eval --quiet --ignore-missing id_ed25519 id_ecdsa id_dsa id_rockrobo old_id_ed25519)
# PAZI
if command -v pazi &>/dev/null; then
eval "$(pazi init zsh)"
fi
export LANG=en_GB.UTF-8
export LC_CTYPE=en_GB.UTF-8
export EDITOR='nvim'
# FZF
export FZF_DEFAULT_COMMAND='fd --type f'
# RIPGREP
export RIPGREP_CONFIG_PATH="${HOME}/.ripgrep"
# Java Wayland fix
export _JAVA_AWT_WM_NONREPARENTING=1
# tabtab source for packages
# uninstall by removing these lines
[[ -f ~/.config/tabtab/zsh/__tabtab.zsh ]] && . ~/.config/tabtab/zsh/__tabtab.zsh || true
# Let GPG know which TTY to send password question to
export GPG_TTY=$(tty)
# Add JBang to environment
alias j!=jbang
export PATH="$HOME/.jbang/bin:$PATH"
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"