dotfiles/.zshrc
Brian Pooe 6861ff1e16 feat: add local override hooks for zsh and git
~/.zshrc.local and ~/.gitconfig.local hold machine-specific settings
(secrets, work identity, installer PATH additions) so third-party
installers stop dirtying the tracked configs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 21:16:17 +02:00

135 lines
4.3 KiB
Bash

# Homebrew (Linux) — must come first so brew-installed tools and plugin
# paths below resolve.
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
export PATH="$HOME/.local/bin:$PATH"
# Persistent command history. Keep HISTSIZE larger than SAVEHIST so zsh has
# room to merge history from other active shells before trimming the file.
HISTFILE="$HOME/.zsh_history"
HISTSIZE=100000
SAVEHIST=80000
setopt SHARE_HISTORY
setopt HIST_REDUCE_BLANKS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
# ===================== User-tunable environment ========================
# Single place to control the look of the whole stack.
export KANAGAWA_THEME="wave" # wave | dragon
export WEZTERM_FONT_SIZE="13"
export WEZTERM_WINDOW_OPACITY="0.9"
export WEZTERM_TEXT_OPACITY="1.0"
# ========================================================================
# Theme (kanagawa variants: dragon|wave)
case "${KANAGAWA_THEME}" in
wave|kanagawa-wave)
export TMUX_THEME="wave"
export NVIM_THEME="wave"
export STARSHIP_THEME="wave"
export WEZTERM_THEME="wave"
export STARSHIP_CONFIG="$HOME/.config/starship/starship-wave.toml"
;;
*)
export TMUX_THEME="dragon"
export NVIM_THEME="dragon"
export STARSHIP_THEME="dragon"
export WEZTERM_THEME="dragon"
export STARSHIP_CONFIG="$HOME/.config/starship/starship.toml"
;;
esac
# Generate the theme files consumed by GUI-launched WezTerm and tmux.
if command -v dotfiles-apply-theme >/dev/null 2>&1; then
dotfiles-apply-theme
fi
# Starship
if command -v starship >/dev/null 2>&1; then
eval "$(starship init zsh)"
fi
# zoxide - a better cd command
if command -v zoxide >/dev/null 2>&1; then
eval "$(zoxide init zsh)"
fi
# Syntax highlighting
for _p in \
"$HOMEBREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" \
/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
do
[ -f "$_p" ] && source "$_p" && break
done
# Disable underline
(( ${+ZSH_HIGHLIGHT_STYLES} )) || typeset -A ZSH_HIGHLIGHT_STYLES
ZSH_HIGHLIGHT_STYLES[path]=none
ZSH_HIGHLIGHT_STYLES[path_prefix]=none
# Autosuggestions
# The plugin default is intentionally dim and becomes unreadable with a
# transparent terminal background.
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#938aa9'
for _p in \
"$HOMEBREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh" \
/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
do
[ -f "$_p" ] && source "$_p" && break
done
# ------------FZF--------------
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
export FZF_DEFAULT_OPTS="--height 50% --layout=default --border --color=hl:#2dd4bf"
export FZF_CTRL_T_OPTS="--preview 'bat --color=always -n --line-range :500 {}'"
export FZF_ALT_C_OPTS="--preview 'eza --icons=always --tree --color=always {} | head -200'"
export FZF_TMUX_OPTS=" -p90%,70% "
# fzf key bindings and completion
if command -v fzf >/dev/null 2>&1; then
source <(fzf --zsh)
fi
unset _p
# -----------------------------
unalias lt 2>/dev/null
lt() {
local level=${1:-3}
(( $# )) && shift
eza --tree --all --level "$level" "$@"
}
# aliases
alias zshconfig="nvim ~/.zshrc"
alias nvimconfig="nvim ~/.config/nvim"
alias dev="cd $HOME/Documents"
alias ls="eza --no-filesize --long --color=always --icons=always --no-user"
alias ll="eza -lah --group-directories-first --no-filesize --long --color=always --icons=always --no-user"
alias vim="nvim"
alias crq="cargo run -q"
alias sudo="sudo "
alias lg="lazygit"
alias update="brew upgrade && sudo apt update && sudo apt upgrade -y"
export DOTFILES_AUTO_TMUX="${DOTFILES_AUTO_TMUX:-0}"
if [ "$DOTFILES_AUTO_TMUX" = "1" ] \
&& command -v tmux &>/dev/null \
&& [ -z "$TMUX" ] \
&& [ -z "$SSH_CONNECTION" ]
then
tmux attach -t default 2>/dev/null || tmux new -s default
fi
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# Machine-specific overrides (secrets, work proxies, installer PATH
# additions). Never tracked in the repo — keep this line last so local
# settings win.
[ -f "$HOME/.zshrc.local" ] && source "$HOME/.zshrc.local"