1
0
Fork 0
gnu-plus-dotfiles/dot_zshrc.tmpl
rain 1b596bd894 Add /opt/rocm/bin to PATH in zshrc when it exists
ROCm installs to /opt/rocm (not /opt/rocm-X.Y versioning). The
upstream /etc/profile.d/rocm.sh tries to add /opt/rocm/bin to PATH
but uses 'append_path' which is a fish-shell function, not a bash/zsh
built-in — so on a zsh login the export is a no-op and the rocm
tools (amd-smi, rocm-smi, rocminfo, hipcc, etc.) are unreachable
without explicit PATH setup.

Add /opt/rocm/bin to the top of the path array in dot_zshrc.tmpl
when the directory exists on the host. Use stat() with the
not-(not-...) bool coercion (pitfall #35 in the chezmoi-bootstrap-
runbook skill) to avoid rendering the stat map's string repr.

Conditional on the directory existing so Pis (no ROCm) don't get a
dead PATH entry. Verified on miche:
  PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/bin/site_perl:    /usr/bin/vendor_perl:/usr/bin/core_perl:/opt/rocm/bin
  /opt/rocm/bin/amd-smi
  /opt/rocm/bin/rocm-smi
  /opt/rocm/bin/rocminfo

amd-smi version: AMDSMI Tool: 26.4.0+3309c6114a | ROCm version: 7.13.0
2026-06-22 19:16:31 -04:00

207 lines
No EOL
8.2 KiB
Cheetah

# =============================================================================
# .zshrc — gnu-plus-dotfiles (chezmoi-managed)
# Refactored from miche's original to use os_family for OS-specific bits.
# Sync source: https://git.melonbread.xyz/rain/gnu-plus-dotfiles
# =============================================================================
# ---------------------------------------------------------------------------
# Oh My Zsh
# ---------------------------------------------------------------------------
export ZSH="$HOME/.oh-my-zsh"
# No theme — using starship
ZSH_THEME=""
# Plugins (loaded before starship so prompt is clean)
plugins=(
git
fzf
sudo # ESC ESC to add sudo
tmux
systemd
rust
rsync
command-not-found
fzf-tab # navigable Tab completion menu
zsh-syntax-highlighting # fish-style live colors — MUST be near last
zsh-history-substring-search # fish-style Up/Down history search
zsh-autosuggestions # fish-style ghost completions — MUST be last
)
source $ZSH/oh-my-zsh.sh
# ---------------------------------------------------------------------------
# History
# ---------------------------------------------------------------------------
setopt EXTENDED_HISTORY # write timestamp + duration
setopt HIST_IGNORE_DUPS # don't save consecutive duplicates
setopt HIST_IGNORE_ALL_DUPS # remove older duplicates of new commands
setopt HIST_IGNORE_SPACE # commands starting with space → not saved
setopt HIST_REDUCE_BLANKS # trim whitespace
setopt SHARE_HISTORY # share history across sessions in real time
setopt INC_APPEND_HISTORY # append immediately
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
# ---------------------------------------------------------------------------
# Shell options — make zsh feel like fish
# ---------------------------------------------------------------------------
setopt AUTO_CD # `dirname` to cd (like fish)
setopt AUTO_PUSHD # cd pushes to dir stack
setopt PUSHD_IGNORE_DUPS
setopt INTERACTIVE_COMMENTS # # comments in interactive shell
setopt EXTENDED_GLOB
setopt NO_BEEP
# Ctrl+Space to accept autosuggestion (like fish)
bindkey '^ ' autosuggest-accept
# Up/Down arrows → history substring search (like fish)
# Both raw form (foot, kitty, alacritty, xterm default) and app-cursor form
# (some terminals in DECCKM mode). Unquoted so $terminfo expands.
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# App-cursor mode: some terminals send ${terminfo[kcuu1]} when DECCKM is set.
# Guard so an unset terminfo entry doesn't warn at startup.
if (( ${+terminfo[kcuu1]} )) && [[ -n "${terminfo[kcuu1]}" ]]; then
bindkey "${terminfo[kcuu1]}" history-substring-search-up
fi
if (( ${+terminfo[kcud1]} )) && [[ -n "${terminfo[kcud1]}" ]]; then
bindkey "${terminfo[kcud1]}" history-substring-search-down
fi
# ---------------------------------------------------------------------------
# Environment Variables
# ---------------------------------------------------------------------------
export EDITOR=nvim
export LANG=en_US.UTF-8
export TMUX_PLUGIN_MANAGER_PATH=~/.tmux/plugins/tpm
{{ if eq .os_family "arch" -}}
# ROCm — on Arch/CachyOS, system handles ROCM_PATH and library paths via
# /etc/profile.d/rocm.sh + /etc/ld.so.conf.d/rocm.conf.
{{ else if eq .os_family "debian" -}}
# Debian: ROCm only relevant if you install it. Leave default until needed.
{{ end -}}
# ---------------------------------------------------------------------------
# PATH (auto-deduplicated)
# ---------------------------------------------------------------------------
typeset -U path
path=(
{{- if not (not (stat "/opt/rocm/bin")) }}
/opt/rocm/bin # ROCm tools first (rocminfo, rocm-smi, amd-smi, hipcc, etc.)
{{- end }}
$HOME/.local/bin
$HOME/.bin
$path
)
# ---------------------------------------------------------------------------
# Aliases — common + OS-specific
# ---------------------------------------------------------------------------
# Directory navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# Modern CLI replacements
alias cat='bat'
alias ls='eza -al --color=always --group-directories-first --icons'
alias ll='eza -l --color=always --group-directories-first --icons'
alias la='eza -a --color=always --group-directories-first --icons'
alias lt='eza -aT --color=always --group-directories-first --icons'
{{ if eq .os_family "arch" -}}
# Pacman / system (Arch-base only)
alias update='sudo pacman -Syu'
alias cleanup='sudo pacman -Rns $(pacman -Qtdq)'
alias fixpacman='sudo rm /var/lib/pacman/db.lck'
alias mirror='sudo cachyos-rate-mirrors || sudo pacman -Syy'
alias please='sudo'
alias jctl='journalctl -p 3 -xb'
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
alias hw='hwinfo --short'
alias gitpkg='pacman -Q | grep -i "\-git" | wc -l'
{{ else if eq .os_family "debian" -}}
# Apt / system (Debian-base only)
alias update='sudo apt update && sudo apt upgrade'
alias please='sudo'
alias jctl='journalctl -p 3 -xb'
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
{{ end -}}
# Utilities
alias weather='curl wttr.in'
alias wget='wget -c '
alias untar='tar -zxvf '
alias tarnow='tar -acf '
# Media
alias yt-dlp-mp4="yt-dlp --format 'bestvideo[height<=720]+bestaudio[ext=m4a]/best[ext=mp4]' --merge-output-format mp4 --remux-video mp4 --audio-quality 128k"
alias yt-dlp-mp4-fedi="yt-dlp --format 'bestvideo[height<=480]+bestaudio[ext=m4a]/best[ext=mp4]' --merge-output-format mp4 --remux-video mp4 --audio-quality 128k"
# Personal
alias toolbox='distrobox'
alias huggingface-cli='hf'
# Quick reload / edit
alias zshsource='source ~/.zshrc'
alias zshconfig='chezmoi edit ~/.zshrc'
# ---------------------------------------------------------------------------
# TERM / TTY fixes (ported from fish config)
# ---------------------------------------------------------------------------
if [[ -z "$TERM" || "$TERM" == "foot-extra" || "$TERM" == "foot+base" ]]; then
if [[ -n "$WAYLAND_DISPLAY" ]] && infocmp foot >/dev/null 2>&1; then
export TERM=foot
elif [[ "$(tty 2>/dev/null)" == /dev/tty* ]]; then
export TERM=linux
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
fi
if [[ -z "$COLORTERM" && -n "$WAYLAND_DISPLAY" ]]; then
export COLORTERM=truecolor
fi
# TTY tint (only on real text TTY)
if [[ -z "$DISPLAY" && "$(tty 2>/dev/null)" == /dev/tty* ]]; then
setterm -background black -foreground white 2>/dev/null
export LS_COLORS='di=33:ln=36:ex=32:so=35:bd=33;1:cd=33:pi=33:fi=0:*.tar=31:*.zip=31:*.gz=31:*.tgz=31:*.jpg=35:*.png=35:*.gif=35:*.mp3=36:*.mp4=36:*.conf=37:*.log=33:*.sh=32:*.py=32'
fi
# ---------------------------------------------------------------------------
# Integrations
# ---------------------------------------------------------------------------
eval "$(starship init zsh)"
eval "$(zoxide init zsh)"
eval "$(fzf --zsh 2>/dev/null)"
# ---------------------------------------------------------------------------
# Custom functions — sourced if present (host-specific, not chezmoi-managed)
# ---------------------------------------------------------------------------
[[ -f ~/.config/zsh/functions.zsh ]] && source ~/.config/zsh/functions.zsh
# ---------------------------------------------------------------------------
# Bun (if installed)
# ---------------------------------------------------------------------------
[[ -d "$HOME/.bun/bin" ]] && export PATH="$HOME/.bun/bin:$PATH"
# ---------------------------------------------------------------------------
# Engram persistent memory — default points at kaiser.local:7438 if unset
# ---------------------------------------------------------------------------
export ENGRAM_URL="${ENGRAM_URL:-http://kaiser.local:7438}"
# ---------------------------------------------------------------------------
# Fastfetch — run on every interactive shell start
# ---------------------------------------------------------------------------
if command -v fastfetch >/dev/null 2>&1; then
fastfetch
fi