feat: omz -> direct, z -> zoxide, rg and fzf bindings

This commit is contained in:
2026-02-12 10:35:02 +00:00
parent 41c8b97786
commit 2486afd158
6 changed files with 120 additions and 47 deletions

View File

@@ -26,3 +26,4 @@ by invoking the `setup-new` script directly via `curl`:
# Run # Run
curl -s https://raw.githubusercontent.com/andrejusk/dotfiles/HEAD/script/setup-new | bash curl -s https://raw.githubusercontent.com/andrejusk/dotfiles/HEAD/script/setup-new | bash

View File

@@ -1,6 +1,7 @@
alias bench='ZSH_BENCH=1 exec zsh' alias bench='ZSH_BENCH=1 exec zsh'
alias dots='cd $DOTFILES' alias dots='cd $DOTFILES'
alias j='z' alias j='z'
alias ji='zi'
alias reload='source ~/.zshrc' alias reload='source ~/.zshrc'
alias reload-path='rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/dots/path" && exec zsh' alias reload-path='rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/dots/path" && exec zsh'
alias reload-cache='rm -rf "${XDG_CACHE_HOME:-$HOME/.cache}/dots" ~/.zcompdump* && exec zsh' alias reload-cache='rm -rf "${XDG_CACHE_HOME:-$HOME/.cache}/dots" ~/.zcompdump* && exec zsh'

View File

@@ -31,29 +31,89 @@ _dots_cache_ls_colors
[[ -f ~/.aliases ]] && source ~/.aliases [[ -f ~/.aliases ]] && source ~/.aliases
_dots_load_omz() { _dots_init_completion() {
export DISABLE_AUTO_UPDATE="true" # Add custom completions to fpath
export DISABLE_LS_COLORS="true" local comp_dir="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/completions"
export ZSH="$HOME/.oh-my-zsh" [[ -d "$comp_dir" ]] && fpath=("$comp_dir" $fpath)
export ZSH_THEME=""
plugins=(
z
zsh-autosuggestions
zsh-syntax-highlighting
)
# Daily security check: skip compaudit if already checked today autoload -Uz compinit
local marker="$_dots_cache_dir/.compaudit_checked" # Rebuild zcompdump at most once per day
local today=$(date +'%Y-%j') local dump="$HOME/.zcompdump"
if [[ -f "$marker" ]] && [[ "$(cat "$marker" 2>/dev/null)" == "$today" ]]; then if [[ -f "$dump" && $(date +'%j') == $(stat -f '%Sm' -t '%j' "$dump" 2>/dev/null || date -r "$dump" +'%j' 2>/dev/null) ]]; then
export ZSH_DISABLE_COMPFIX="true" compinit -C
else else
echo "$today" > "$marker" compinit
fi fi
source "$ZSH/oh-my-zsh.sh"
} }
_dots_load_omz _dots_init_completion
_dots_load_plugins() {
local plugin_dir="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins"
# autosuggestions first
local f="$plugin_dir/zsh-autosuggestions/zsh-autosuggestions.zsh"
[[ -f "$f" ]] && source "$f"
# syntax-highlighting must be last
f="$plugin_dir/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
[[ -f "$f" ]] && source "$f"
}
_dots_load_plugins
_dots_load_history() {
HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/history"
HISTSIZE=50000
SAVEHIST=50000
mkdir -p "$(dirname "$HISTFILE")"
setopt HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY
}
_dots_load_history
_dots_load_keybindings() {
bindkey -e
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
# Ctrl+J: interactive zoxide jump (zi)
_dots_zoxide_widget() {
local result
result="$(zoxide query -i -- 2>&1)" && cd "$result"
zle reset-prompt
}
zle -N _dots_zoxide_widget
bindkey '^J' _dots_zoxide_widget
}
_dots_load_keybindings
_dots_load_fzf() {
command -v fzf &>/dev/null || return
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git"'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS='--layout=reverse --height=40% --prompt="> " --info=inline-right --no-separator'
# Modern fzf (v0.48+) provides --zsh
if fzf --zsh &>/dev/null; then
source <(fzf --zsh)
else
# Fallback paths for shell integration
local -a fzf_paths=(
"${HOMEBREW_PREFIX:-/opt/homebrew}/opt/fzf/shell"
"/usr/share/fzf"
"${XDG_DATA_HOME:-$HOME/.local/share}/fzf/shell"
)
for dir in "${fzf_paths[@]}"; do
[[ -f "$dir/key-bindings.zsh" ]] && source "$dir/key-bindings.zsh" && break
done
for dir in "${fzf_paths[@]}"; do
[[ -f "$dir/completion.zsh" ]] && source "$dir/completion.zsh" && break
done
fi
}
_dots_load_zoxide() {
command -v zoxide &>/dev/null || return
export _ZO_FZF_OPTS="$FZF_DEFAULT_OPTS"
eval "$(zoxide init zsh)"
}
# Prompt # Prompt
(( ${+PROMPT_MIN_DURATION} )) || typeset -gi PROMPT_MIN_DURATION=2 # show duration after N seconds (( ${+PROMPT_MIN_DURATION} )) || typeset -gi PROMPT_MIN_DURATION=2 # show duration after N seconds
@@ -340,5 +400,7 @@ _dots_load_mise() {
command -v mise &>/dev/null && eval "$(mise activate zsh)" command -v mise &>/dev/null && eval "$(mise activate zsh)"
} }
_dots_load_mise _dots_load_mise
_dots_load_fzf
_dots_load_zoxide
[[ -n "$ZSH_BENCH" ]] && zprof || true [[ -n "$ZSH_BENCH" ]] && zprof || true

View File

@@ -2,7 +2,7 @@
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Description: # Description:
# Configure zsh shell. # Configure zsh shell with direct plugin management.
# #
# install zsh # install zsh
@@ -26,28 +26,33 @@ fi
zsh --version zsh --version
# install oh-my-zsh # plugin directory (XDG compliant)
export ZSH="$HOME/.oh-my-zsh" PLUGIN_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins"
if [ ! -d "$ZSH" ]; then mkdir -p "$PLUGIN_DIR"
# https://github.com/ohmyzsh/ohmyzsh#unattended-install
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
export ZSH_CUSTOM="$ZSH/custom"
# install zsh-syntax-highlighting
export ZSH_SYNTAX_HIGHLIGHTING="$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
if [ ! -d "$ZSH_SYNTAX_HIGHLIGHTING" ]; then
git clone -q \
https://github.com/zsh-users/zsh-syntax-highlighting.git \
"$ZSH_SYNTAX_HIGHLIGHTING"
fi
# install zsh-autosuggestions # install zsh-autosuggestions
export ZSH_AUTOSUGGESTIONS="$ZSH_CUSTOM/plugins/zsh-autosuggestions" if [ ! -d "$PLUGIN_DIR/zsh-autosuggestions" ]; then
if [ ! -d "$ZSH_AUTOSUGGESTIONS" ]; then
git clone -q \ git clone -q \
https://github.com/zsh-users/zsh-autosuggestions.git \ https://github.com/zsh-users/zsh-autosuggestions.git \
"$ZSH_AUTOSUGGESTIONS" "$PLUGIN_DIR/zsh-autosuggestions"
fi
# install zsh-syntax-highlighting
if [ ! -d "$PLUGIN_DIR/zsh-syntax-highlighting" ]; then
git clone -q \
https://github.com/zsh-users/zsh-syntax-highlighting.git \
"$PLUGIN_DIR/zsh-syntax-highlighting"
fi
# warn about legacy oh-my-zsh directory
if [ -d "$HOME/.oh-my-zsh" ]; then
log_warn "Legacy ~/.oh-my-zsh directory found. Remove with: rm -rf ~/.oh-my-zsh"
fi
# migrate zoxide database from z if available
if command -v zoxide &>/dev/null && [ -f "$HOME/.z" ]; then
log_info "Importing z database into zoxide..."
zoxide import --from z "$HOME/.z" 2>/dev/null || true
fi fi
# change default shell to zsh # change default shell to zsh

View File

@@ -48,6 +48,9 @@ typeset -a MISE_TOOLS=(
"gh@2.86.0" "gh@2.86.0"
"terraform@1.14.4" "terraform@1.14.4"
"firebase@15.5.1" "firebase@15.5.1"
"fzf@latest"
"zoxide@latest"
"ripgrep@latest"
) )
# Install all tools in parallel # Install all tools in parallel
@@ -64,14 +67,11 @@ done
eval "$(mise activate bash)" eval "$(mise activate bash)"
export PATH="$HOME/.local/share/mise/shims:$PATH" export PATH="$HOME/.local/share/mise/shims:$PATH"
# Setup Poetry ZSH completions # Setup Poetry ZSH completions (XDG compliant)
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}" COMPLETIONS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/completions"
if [[ -d "$ZSH_CUSTOM/plugins" ]]; then mkdir -p "$COMPLETIONS_DIR"
POETRY_PLUGIN="$ZSH_CUSTOM/plugins/poetry" if [ ! -f "$COMPLETIONS_DIR/_poetry" ]; then
if [ ! -d "$POETRY_PLUGIN" ]; then mise exec -- poetry completions zsh > "$COMPLETIONS_DIR/_poetry"
mkdir -p "$POETRY_PLUGIN"
mise exec -- poetry completions zsh > "$POETRY_PLUGIN/_poetry"
fi
fi fi
# Verify installations using mise exec # Verify installations using mise exec

View File

@@ -65,6 +65,10 @@ binaries: List[Text] = [
# langauge: js # langauge: js
"node", "node",
"npm", "npm",
# search & navigation
"fzf",
"zoxide",
"rg",
] ]
binaries = [binary for binary in binaries if binary is not None] binaries = [binary for binary in binaries if binary is not None]