204 lines
10 KiB
Bash
204 lines
10 KiB
Bash
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ ZSH Config │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Preoload stuff │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
|
|
export $HOME/.zprofile
|
|
# Set the directory we want to store zinit and plugins
|
|
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
|
|
|
|
# Auto install zinit
|
|
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
|
|
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
|
|
|
|
# Source/Load zinit, installation is handle by chezmoi external script
|
|
source "${ZINIT_HOME}/zinit.zsh"
|
|
|
|
# source catppuccin theme for zsh-syntax-highlighting
|
|
zinit snippet "https://raw.githubusercontent.com/catppuccin/zsh-syntax-highlighting/main/themes/catppuccin_macchiato-zsh-syntax-highlighting.zsh"
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ ZSH plugins │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
|
|
zinit light zsh-users/zsh-syntax-highlighting
|
|
zinit light zsh-users/zsh-completions
|
|
zinit light zsh-users/zsh-autosuggestions
|
|
|
|
{{ #if dotter.packages.fzf }}
|
|
zinit light Aloxaf/fzf-tab
|
|
{{ /if }}
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Oh My Zsh snippets │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
zinit ice as"completion"; zinit snippet "https://raw.githubusercontent.com/sharkdp/fd/master/contrib/completion/_fd"
|
|
zinit ice as"completion"; zinit snippet OMZP::gh
|
|
zinit ice as"completion"; zinit snippet OMZP::docker/completions/_docker
|
|
|
|
# svn is deprecated, zinit is working in replacing in favor of git: https://github.com/zdharma-continuum/zinit/issues/504
|
|
# In the meantime, this plugins will not work
|
|
# zinit ice svn; zinit snippet OMZ::plugins/aliases
|
|
# zinit ice svn; zinit snippet OMZ::plugins/rust
|
|
|
|
zinit snippet OMZP::alias-finder
|
|
zinit snippet OMZP::colored-man-pages
|
|
zinit snippet OMZP::dnf
|
|
zinit snippet OMZP::docker-compose
|
|
zinit snippet OMZP::git
|
|
zinit snippet OMZP::systemd
|
|
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Plugins options │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
zstyle ':completion:*:*:docker:*' option-stacking yes
|
|
zstyle ':completion:*:*:docker-*:*' option-stacking yes
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Load completions │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
# Custom completions
|
|
fpath+=${XDG_CONFIG_HOME:-$HOME/.config}/zsh/completions
|
|
autoload -Uz ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/completions/*
|
|
|
|
autoload -Uz compinit && compinit
|
|
zinit cdreplay -q
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Keybindings │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
bindkey -e
|
|
bindkey '^f' auto-suggest-accept
|
|
bindkey '^p' history-search-backward
|
|
bindkey '^n' history-search-forward
|
|
bindkey '^[w' kill-region
|
|
|
|
# Set VIM keybindings
|
|
bindkey -v
|
|
export KEYTIMEOUT=1
|
|
autoload -Uz edit-command-line
|
|
zle -N edit-command-line
|
|
bindkey -M vicmd V edit-command-line # Edits files in vim, hit Shift+v in normal mode
|
|
|
|
# Add vim text objects
|
|
autoload -Uz select-bracketed select-quoted
|
|
zle -N select-quoted
|
|
zle -N select-bracketed
|
|
for km in viopp visual; do
|
|
bindkey -M $km -- '-' vi-up-line-or-history
|
|
for c in {a,i}${(s..)^:-\'\"\`\|,./:;=+@}; do
|
|
bindkey -M $km $c select-quoted
|
|
done
|
|
for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
|
|
bindkey -M $km $c select-bracketed
|
|
done
|
|
done
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ History │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
HISTSIZE=5000
|
|
HISTFILE=~/.zsh_history
|
|
SAVEHIST=$HISTSIZE
|
|
HISTDUP=erase
|
|
setopt appendhistory
|
|
setopt sharehistory
|
|
setopt hist_ignore_space
|
|
setopt hist_ignore_all_dups
|
|
setopt hist_save_no_dups
|
|
setopt hist_ignore_dups
|
|
setopt hist_find_no_dups
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Completion styling │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
# case insensitive completion
|
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
|
|
|
{{ #if dotter.packages.fzf }}
|
|
|
|
zstyle ':completion:*' menu no
|
|
zstyle ':fzf-tab:*' show-group full
|
|
zstyle ':fzf-tab:*' continuous-trigger '/'
|
|
zstyle ':fzf-tab:*' fzf-flags --height=10% --layout=reverse --info=inline --ansi -i --preview-window=right:60%:wrap
|
|
|
|
# ── Previewers ───────────────────────────────────────────────────────
|
|
|
|
# Directories
|
|
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview \
|
|
'eza -lha --color=always --icons --git --no-permissions --tree --level 3 --group-directories-first --total-size $realpath'
|
|
zstyle ':fzf-tab:complete:cd:*' fzf-preview \
|
|
'eza -lha --color=always --icons --git --no-permissions --tree --level 3 --group-directories-first --total-size $realpath'
|
|
|
|
# systemctl
|
|
zstyle ':fzf-tab:complete:systemctl-*:*' fzf-preview 'SYSTEMD_COLORS=1 systemctl status $word'
|
|
|
|
# git
|
|
zstyle ':fzf-tab:complete:git-(add|diff|restore):*' fzf-preview \
|
|
'git diff $word | bat -plman --color=always'
|
|
zstyle ':fzf-tab:complete:git-log:*' fzf-preview \
|
|
'git log --decorate --graph --color=always $word'
|
|
zstyle ':fzf-tab:complete:git-help:*' fzf-preview \
|
|
'git help $word | bat -plman --color=always'
|
|
zstyle ':fzf-tab:complete:git-show:*' fzf-preview \
|
|
'case "$group" in
|
|
"commit tag") git show --color=always $word ;;
|
|
*) git show --color=always $word | bat -plman --color=always ;;
|
|
esac'
|
|
zstyle ':fzf-tab:complete:git-checkout:*' fzf-preview \
|
|
'case "$group" in
|
|
"modified file") git diff $word | bat -plman --color=always ;;
|
|
"recent commit object name") git show --color=always $word | bat -plman --color=always ;;
|
|
*) git log --decorate --graph --color=always $word ;;
|
|
esac'
|
|
|
|
# TLDR
|
|
zstyle ':fzf-tab:complete:tldr:argument-1' fzf-preview 'tldr --color always $word'
|
|
|
|
{{ /if }}
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ ZSH Options │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
setopt EXTENDED_GLOB
|
|
setopt DOT_GLOB
|
|
setopt GLOB_DOTS
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Source other files │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
|
|
{{ #if dotter.packages.fzf }}
|
|
source $HOME/.config/fzf/fzfrc
|
|
{{ /if }}
|
|
|
|
# this prevents errors and not loading some files
|
|
for file in $HOME/.config/zsh/**/*.zsh; do
|
|
source $file
|
|
done
|
|
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Init external programs │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
|
|
{{ #if dotter.packages.fzf }}
|
|
eval "$(fzf --zsh)"
|
|
{{ /if ~}}
|
|
|
|
{{ #if (is_executable "zoxide") }}
|
|
eval "$(zoxide init --cmd cd zsh)"
|
|
{{ /if ~}}
|
|
|
|
{{ #if dotter.packages.starship }}
|
|
eval "$(starship init zsh)"
|
|
{{ /if ~}}
|
|
|
|
{{ #if (is_executable "mise") }}
|
|
eval "$(mise activate zsh)"
|
|
{{ /if ~}}
|