102 lines
3.2 KiB
Bash
102 lines
3.2 KiB
Bash
# Set the directory we want to store zinit and plugins
|
|
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
|
|
|
|
# Download Zinit, if it's not there yet
|
|
if [ ! -d "$ZINIT_HOME" ]; then
|
|
mkdir -p "$(dirname $ZINIT_HOME)"
|
|
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
|
|
fi
|
|
|
|
# Source/Load zinit
|
|
source "${ZINIT_HOME}/zinit.zsh"
|
|
|
|
# Add in zsh plugins
|
|
zinit light zsh-users/zsh-syntax-highlighting
|
|
zinit light zsh-users/zsh-completions
|
|
zinit light zsh-users/zsh-autosuggestions
|
|
zinit light Aloxaf/fzf-tab
|
|
|
|
# Add in snippets
|
|
zinit snippet OMZL::git.zsh
|
|
zinit snippet OMZP::git
|
|
zinit snippet OMZP::sudo
|
|
zinit snippet OMZP::archlinux
|
|
zinit snippet OMZP::aws
|
|
zinit snippet OMZP::kubectl
|
|
zinit snippet OMZP::kubectx
|
|
zinit snippet OMZP::command-not-found
|
|
|
|
# Load completions
|
|
autoload -Uz compinit && compinit
|
|
|
|
zinit cdreplay -q
|
|
|
|
# Prompt
|
|
eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/zen.toml)"
|
|
|
|
# --- Keybindings
|
|
|
|
# Use emacs keybindings
|
|
bindkey -e
|
|
|
|
# History search
|
|
bindkey '^p' history-search-backward # Ctrl+P for previous history entry
|
|
bindkey '^n' history-search-forward # Ctrl+N for next history entry
|
|
|
|
# Word navigation
|
|
bindkey "^[[1;5C" forward-word # Ctrl+Right Arrow to move forward by word
|
|
bindkey "^[[1;5D" backward-word # Ctrl+Left Arrow to move backward by word
|
|
|
|
# Non-Tmux bindings (direct terminal)
|
|
bindkey "^[[A" up-line-or-history # Up Arrow key
|
|
bindkey "^[[B" down-line-or-history # Down Arrow key
|
|
bindkey "^[[C" forward-char # Right Arrow key
|
|
bindkey "^[[D" backward-char # Left Arrow key
|
|
bindkey "^[[H" beginning-of-line # Home key
|
|
bindkey "^[[F" end-of-line # End key
|
|
bindkey "^[[2~" overwrite-mode # Insert key (toggle overwrite mode)
|
|
bindkey "^[[3~" delete-char # Delete key
|
|
|
|
# Tmux bindings (if sequences differ under Tmux)
|
|
bindkey "^[[1~" beginning-of-line # Home key (Tmux)
|
|
bindkey "^[[4~" end-of-line # End key (Tmux)
|
|
bindkey "^[[3~" delete-char # Delete key (Tmux)
|
|
bindkey "^[[A" up-line-or-history # Up Arrow key (Tmux)
|
|
bindkey "^[[B" down-line-or-history # Down Arrow key (Tmux)
|
|
bindkey "^[[C" forward-char # Right Arrow key (Tmux)
|
|
bindkey "^[[D" backward-char # Left Arrow key (Tmux)
|
|
|
|
# ---
|
|
|
|
# History
|
|
HISTSIZE=10000
|
|
HISTFILE=~/.zsh_history
|
|
SAVEHIST=$HISTSIZE
|
|
setopt appendhistory
|
|
setopt sharehistory
|
|
setopt hist_ignore_space
|
|
setopt hist_ignore_all_dups
|
|
setopt hist_find_no_dups
|
|
|
|
# Completion styling
|
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
|
zstyle ':completion:*' menu no
|
|
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
|
|
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
|
|
|
|
# Aliases
|
|
alias ls='ls --color=auto'
|
|
alias grep='grep --color=auto'
|
|
alias v='nvim'
|
|
alias c='clear'
|
|
|
|
# Shell integrations
|
|
eval "$(fzf --zsh)"
|
|
eval "$(zoxide init --cmd cd zsh)"
|
|
|
|
# Automatically start Tmux (currently handled in Alacritty)
|
|
#if [ -x "$(command -v tmux)" ] && [ -n "${DISPLAY}" ] && [ -z "${TMUX}" ] && [[ "$TERM_PROGRAM" != "vscode" ]]; then
|
|
# exec tmux new-session -A -s ${USER} >/dev/null 2>&1
|
|
#fi
|