]> git.quilime.com - cfg.git/commitdiff
Optimizations
authorGabriel Dunne <gdunne@quilime.com>
Sat, 19 Sep 2026 19:44:14 +0000 (12:44 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sat, 19 Sep 2026 19:44:14 +0000 (12:44 -0700)
.zsh/common.zsh
.zsh/local.zsh.example [deleted file]
.zsh/macos.zsh

index 7295d545e1a9831e82a4a4ab8cd5f9b28ea0316d..13db3ce190e89055ea00e6ff2bef50cc5c4a8285 100644 (file)
@@ -1,20 +1,22 @@
-# Shared Zsh settings
-
-setopt correct extendedglob nocaseglob rcexpandparam nocheckjobs
-setopt numericglobsort nobeep appendhistory histignorealldups autocd prompt_subst
-
 HISTFILE="$HOME/.zsh_history"
 HISTSIZE=100000
 SAVEHIST=100000
+
+setopt correct extendedglob nocaseglob rcexpandparam nocheckjobs
+setopt numericglobsort nobeep appendhistory histignorealldups autocd prompt_subst
 setopt share_history hist_ignore_all_dups hist_ignore_space hist_reduce_blanks extended_history
 
 export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43'
 
-# Completion
-if command -v brew >/dev/null 2>&1; then
-    FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
+# Add Homebrew completion definitions without launching Homebrew at shell startup.
+if [[ -d /opt/homebrew/share/zsh/site-functions ]]; then
+    FPATH="/opt/homebrew/share/zsh/site-functions:${FPATH}"
+elif [[ -d /usr/local/share/zsh/site-functions ]]; then
+    FPATH="/usr/local/share/zsh/site-functions:${FPATH}"
 fi
+
 autoload -Uz compinit
+# Rebuild the completion cache only when it is more than 24 hours old.
 if [[ -n ~/.zcompdump(#qN.mh+24) ]]; then compinit; else compinit -C; fi
 zstyle ':completion:*' menu no
 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
@@ -27,7 +29,10 @@ zstyle ':completion:*' verbose yes use-cache on
 zstyle ':completion:*' cache-path "$HOME/.zsh/cache"
 setopt complete_in_word auto_menu
 
-# Prompt
+# dotifles config
+alias cfg='git --git-dir="$HOME/.cfg" --work-tree="$HOME"'
+
+# git prompt info
 autoload -Uz vcs_info
 precmd_vcs_info() { vcs_info }
 precmd_functions+=(precmd_vcs_info)
@@ -35,21 +40,21 @@ zstyle ':vcs_info:git:*' formats '%b'
 PROMPT='%F{cyan}%n@%m%f %F{240}%1~%f %F{cyan}❯%f '
 RPROMPT='%F{green}${vcs_info_msg_0_} %F{240}%*%f'
 
+# emacs-style command-line editing.
 bindkey -e
+# treat /, &, ., and ; as word boundaries when editing.
 WORDCHARS=${WORDCHARS//\/[&.;]}
 
-# Smart cd; its database remains local to this machine.
+# cd-smart
 export CDS_DB="$HOME/.local/state/cd-smart.tsv"
 source "$HOME/.zsh/cd-smart.zsh"
 
 alias grep='grep --color'
-alias cfg='git --git-dir="$HOME/.cfg" --work-tree="$HOME"'
+
 export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
 
-# fzf, when installed
+# Load fzf integration only when fzf is installed.
 if command -v fzf >/dev/null 2>&1; then
     export FZF_CTRL_R_OPTS="--height=~15 --layout=reverse --no-info --no-separator --no-scrollbar --prompt='history › ' --scheme=history --with-nth 2.."
     source <(fzf --zsh)
 fi
-
-# fzf-tab and optional plugins are loaded by the platform file when available.
diff --git a/.zsh/local.zsh.example b/.zsh/local.zsh.example
deleted file mode 100644 (file)
index 10c5c1c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copy to ~/.zsh/local.zsh for machine- or work-specific settings.
-# Keep this file out of shared/public dotfiles.
-
-# Examples:
-# AWS configuration is usually best managed in ~/.aws/config.
-# If a machine-wide default is needed, set it here with generic values:
-# export AWS_PROFILE=your-profile
-# export AWS_REGION=your-region
-#
-# Put any other machine-specific paths or environment variables here.
index 6361021ece517630cab6631cbd3b291f6fee9225..06f728e91388d33bfaf81b5baa569732ce61d0e8 100644 (file)
@@ -3,16 +3,29 @@
 alias ls='ls -G'
 alias x86='arch -x86_64 zsh'
 
-if command -v brew >/dev/null 2>&1; then
-    eval "$(brew shellenv)"
-    if [[ -r "$(brew --prefix)/opt/fzf-tab/share/fzf-tab/fzf-tab.zsh" ]]; then
-        source "$(brew --prefix)/opt/fzf-tab/share/fzf-tab/fzf-tab.zsh"
-        [[ -r "$HOME/.zsh/fzf-tab.zsh" ]] && source "$HOME/.zsh/fzf-tab.zsh"
-    fi
-    [[ -r "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" ]] && \
-        source "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
-    [[ -r "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]] && \
-        source "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
+# Homebrew is normally installed under /opt/homebrew on Apple Silicon and
+# /usr/local on Intel Macs. Use the known path to avoid repeated `brew --prefix`
+# subprocesses while starting a shell.
+if [[ -x /opt/homebrew/bin/brew ]]; then
+    HOMEBREW_PREFIX=/opt/homebrew
+elif [[ -x /usr/local/bin/brew ]]; then
+    HOMEBREW_PREFIX=/usr/local
+fi
+
+if [[ -n ${HOMEBREW_PREFIX:-} ]]; then
+    # Add Homebrew's tools to the environment without running `brew shellenv`.
+    export PATH="$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:$PATH"
+    export MANPATH="$HOMEBREW_PREFIX/share/man${MANPATH:+:$MANPATH}"
+    export INFOPATH="$HOMEBREW_PREFIX/share/info${INFOPATH:+:$INFOPATH}"
+
+    [[ -r "$HOMEBREW_PREFIX/opt/fzf-tab/share/fzf-tab/fzf-tab.zsh" ]] && \
+        source "$HOMEBREW_PREFIX/opt/fzf-tab/share/fzf-tab/fzf-tab.zsh"
+    [[ -r "$HOME/.zsh/fzf-tab.zsh" ]] && source "$HOME/.zsh/fzf-tab.zsh"
+    [[ -r "$HOMEBREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh" ]] && \
+        source "$HOMEBREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
+    # Syntax highlighting must remain the final plugin loaded.
+    [[ -r "$HOMEBREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]] && \
+        source "$HOMEBREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
 fi
 
 [[ -r "$HOME/.docker/init-zsh.sh" ]] && source "$HOME/.docker/init-zsh.sh"