Files
ansible-playbooks/roles/zsh/templates/zshrc.j2
T
2026-05-05 22:58:56 +02:00

87 lines
3.1 KiB
Django/Jinja

# {{ ansible_managed }}
export ZSH_PLUGINS={{ zsh_plugins_path }}
# History configuration
HISTFILE={{ zsh_config_path }}/.zsh_history
HISTSIZE=50000
SAVEHIST=50000
setopt EXTENDED_HISTORY # record timestamp of command
setopt HIST_EXPIRE_DUPS_FIRST # delete duplicates first when trimming
setopt HIST_IGNORE_DUPS # ignore duplicated commands
setopt HIST_IGNORE_SPACE # ignore commands starting with space
setopt HIST_VERIFY # show command with history expansion before running
setopt SHARE_HISTORY # share history between sessions
setopt APPEND_HISTORY # append to history file, don't overwrite
# Directory navigation
setopt AUTO_CD # cd by typing directory name
setopt AUTO_PUSHD # push directories on cd
setopt PUSHD_IGNORE_DUPS # don't push duplicates
setopt CORRECT # correct command spelling
setopt NO_BEEP # no beeps
# Force emacs keybindings (zsh defaults to vi when EDITOR=vim)
bindkey -e
# Completion
autoload -Uz compinit
compinit -C # faster completion (cache)
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
if [[ -r "$HOME/.cache/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "$HOME/.cache/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Enable powerlevel10k theme
source $ZSH_PLUGINS/powerlevel10k/powerlevel10k.zsh-theme
# Load powerlevel10k configuration
source {{ zsh_p10k_theme_config }}
# Exclude forward-word from partial-accept so that Opt+Right always navigates
# instead of accepting the next word from the autosuggestion.
# Right arrow (forward-char) still accepts the full suggestion.
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
emacs-forward-word
vi-forward-word
vi-forward-word-end
vi-forward-blank-word
vi-forward-blank-word-end
vi-find-next-char
vi-find-next-char-skip
)
# Enable autosuggestions (before syntax highlighting)
source $ZSH_PLUGINS/zsh-autosuggestions/zsh-autosuggestions.zsh
# Enable history substring search (before keybindings, before syntax highlighting)
source $ZSH_PLUGINS/zsh-history-substring-search/zsh-history-substring-search.zsh
# Enable syntax highlighting (must be loaded last)
source $ZSH_PLUGINS/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Enable fzf integration (Ctrl+R, Ctrl+T, Alt+C)
source /usr/share/fzf/key-bindings.zsh
source /usr/share/fzf/completion.zsh
# Enable fzf-tab for completions (after compinit)
source $ZSH_PLUGINS/fzf-tab/fzf-tab.zsh
# Source fzf-tab config
[[ -f {{ zsh_config_path }}/fzf-tab.zsh ]] && source {{ zsh_config_path }}/fzf-tab.zsh
# Source aliases
[[ -f {{ zsh_config_path }}/aliases ]] && source {{ zsh_config_path }}/aliases
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
# Useful keybindings
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down
# Line and word navigation (Alacritty Cmd/Opt+arrow compatibility)
bindkey '\eOH' beginning-of-line # Home / Cmd+Left
bindkey '\eOF' end-of-line # End / Cmd+Right
bindkey '\eb' backward-word # Opt+Left
bindkey '\ef' forward-word # Opt+Right