Commit f9a1dba194
Verified · cmc
Layout: unified · split
zsh/.zshrc +52 −24
| @@ -1,14 +1,30 @@ | |||
| 1 | # ============================================================================== | 1 | # ============================================================================== |
| 2 | # 1. PRE-INITIALIZATION (Instant Prompt) | 2 | # 1. OS-SPECIFIC CONFIGURATION |
| 3 | # ============================================================================== | 3 | # ============================================================================== |
| 4 | |||
| 5 | # Use uname to detect the OS and set the correct Homebrew path | ||
| 6 | if [[ "$(uname)" == "Darwin" ]]; then | ||
| 7 | # macOS (Apple Silicon) | ||
| 8 | BREW_PREFIX="/opt/homebrew" | ||
| 9 | elif [[ "$(uname)" == "Linux" ]]; then | ||
| 10 | # Linux (Linuxbrew) | ||
| 11 | BREW_PREFIX="/home/linuxbrew/.linuxbrew" | ||
| 12 | fi | ||
| 13 | |||
| 14 | # ============================================================================== | ||
| 15 | # 2. PRE-INITIALIZATION (Instant Prompt) | ||
| 16 | # ============================================================================== | ||
| 17 | |||
| 4 | if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | 18 | if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then |
| 5 | source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | 19 | source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" |
| 6 | fi | 20 | fi |
| 7 | 21 | ||
| 8 | # ============================================================================== | 22 | # ============================================================================== |
| 9 | # 2. ENVIRONMENT VARIABLES & PATH | 23 | # 3. ENVIRONMENT VARIABLES & PATH |
| 10 | # ============================================================================== | 24 | # ============================================================================== |
| 11 | export PATH="/Users/cmc/.local/xonsh-env/xbin:$PATH" | 25 | |
| 26 | export PATH="$HOME/.local/xonsh-env/xbin:$PATH" | ||
| 27 | export PATH="$BRE_PREFIX:$PATH" | ||
| 12 | export GPG_TTY=$(tty) | 28 | export GPG_TTY=$(tty) |
| 13 | 29 | ||
| 14 | # borgbackup | 30 | # borgbackup |
| @@ -17,8 +33,15 @@ mkdir -p /tank/borg-cache | |||
| 17 | 33 | ||
| 18 | # NVM Configuration | 34 | # NVM Configuration |
| 19 | export NVM_DIR="$HOME/.nvm" | 35 | export NVM_DIR="$HOME/.nvm" |
| 20 | [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" | 36 | NVM_SH_PATH="$BREW_PREFIX/opt/nvm/nvm.sh" |
| 21 | [ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" | 37 | if [[ -s "$NVM_SH_PATH" ]]; then |
| 38 | source "$NVM_SH_PATH" | ||
| 39 | fi | ||
| 40 | |||
| 41 | NVM_BASH_COMPLETION_PATH="$BREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" | ||
| 42 | if [[ -s "$NVM_BASH_COMPLETION_PATH" ]]; then | ||
| 43 | source "$NVM_BASH_COMPLETION_PATH" | ||
| 44 | fi | ||
| 22 | 45 | ||
| 23 | # History Settings | 46 | # History Settings |
| 24 | HISTFILE=~/.histfile | 47 | HISTFILE=~/.histfile |
| @@ -26,19 +49,24 @@ HISTSIZE=1000 | |||
| 26 | SAVEHIST=1000 | 49 | SAVEHIST=1000 |
| 27 | 50 | ||
| 28 | # ============================================================================== | 51 | # ============================================================================== |
| 29 | # 3. COMPLETION & UI SETTINGS | 52 | # 4. COMPLETION & UI SETTINGS |
| 30 | # ============================================================================== | 53 | # ============================================================================== |
| 54 | |||
| 31 | bindkey -e | 55 | bindkey -e |
| 32 | zstyle :compinstall filename '/Users/cmc/.zshrc' | 56 | zstyle :compinstall filename "$HOME/.zshrc" |
| 33 | autoload -Uz compinit && compinit | 57 | autoload -Uz compinit && compinit |
| 34 | 58 | ||
| 35 | # Load Theme | 59 | # p10k |
| 36 | source /opt/homebrew/share/powerlevel10k/powerlevel10k.zsh-theme | 60 | P10K_THEME_PATH="$BREW_PREFIX/share/powerlevel10k/powerlevel10k.zsh-theme" |
| 61 | if [[ -f "$P10K_THEME_PATH" ]]; then | ||
| 62 | source "$P10K_THEME_PATH" | ||
| 63 | fi | ||
| 37 | [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh | 64 | [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh |
| 38 | 65 | ||
| 39 | # ============================================================================== | 66 | # ============================================================================== |
| 40 | # 4. ALIASES | 67 | # 5. ALIASES |
| 41 | # ============================================================================== | 68 | # ============================================================================== |
| 69 | |||
| 42 | alias l="ls -lha" | 70 | alias l="ls -lha" |
| 43 | alias emacs="emacs -nw" | 71 | alias emacs="emacs -nw" |
| 44 | alias xclean="find . -name '.DS_Store' -type f -delete" | 72 | alias xclean="find . -name '.DS_Store' -type f -delete" |
| @@ -57,31 +85,31 @@ alias gcob='git checkout -b' | |||
| 57 | alias gma='git checkout main' | 85 | alias gma='git checkout main' |
| 58 | 86 | ||
| 59 | # ============================================================================== | 87 | # ============================================================================== |
| 60 | # 5. PLUGINS (Must be loaded after aliases for best results) | 88 | # 6. PLUGINS (Must be loaded after aliases for best results) |
| 61 | # ============================================================================== | 89 | # ============================================================================== |
| 62 | source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh | ||
| 63 | 90 | ||
| 64 | # Syntax Highlighting MUST be the last thing sourced | 91 | # Zsh Autosuggestions |
| 65 | source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | 92 | ZSH_AUTOSUGGESTIONS_PATH="$BREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh" |
| 93 | if [[ -f "$ZSH_AUTOSUGGESTIONS_PATH" ]]; then | ||
| 94 | source "$ZSH_AUTOSUGGESTIONS_PATH" | ||
| 95 | fi | ||
| 96 | |||
| 97 | # Syntax Highlighting | ||
| 98 | ZSH_SYNTAX_HIGHLIGHTING_PATH="$BREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" | ||
| 99 | if [[ -f "$ZSH_SYNTAX_HIGHLIGHTING_PATH" ]]; then | ||
| 100 | source "$ZSH_SYNTAX_HIGHLIGHTING_PATH" | ||
| 101 | fi | ||
| 66 | 102 | ||
| 67 | # ============================================================================== | 103 | # ============================================================================== |
| 68 | # 6. SYNTAX HIGHLIGHTING CUSTOMIZATION | 104 | # 7. SYNTAX HIGHLIGHTING CUSTOMIZATION |
| 69 | # ============================================================================== | 105 | # ============================================================================== |
| 106 | |||
| 70 | # Must be defined AFTER the plugin is sourced | 107 | # Must be defined AFTER the plugin is sourced |
| 71 | # Colors available: black, red, green, yellow, blue, magenta, cyan, white | 108 | # Colors available: black, red, green, yellow, blue, magenta, cyan, white |
| 72 | # Styles: bold, underline | 109 | # Styles: bold, underline |
| 73 | 110 | ||
| 74 | # Highlight aliases in Cyan | ||
| 75 | ZSH_HIGHLIGHT_STYLES[alias]='fg=cyan,bold' | 111 | ZSH_HIGHLIGHT_STYLES[alias]='fg=cyan,bold' |
| 76 | |||
| 77 | # Highlight standard commands in Green | ||
| 78 | ZSH_HIGHLIGHT_STYLES[command]='fg=green' | 112 | ZSH_HIGHLIGHT_STYLES[command]='fg=green' |
| 79 | |||
| 80 | # Highlight built-ins (like cd, echo) in Magenta | ||
| 81 | ZSH_HIGHLIGHT_STYLES[builtin]='fg=magenta' | 113 | ZSH_HIGHLIGHT_STYLES[builtin]='fg=magenta' |
| 82 | |||
| 83 | # Highlight valid paths in White with an underline | ||
| 84 | ZSH_HIGHLIGHT_STYLES[path]='fg=white,underline' | 114 | ZSH_HIGHLIGHT_STYLES[path]='fg=white,underline' |
| 85 | |||
| 86 | # Highlight errors (typos) in Red | ||
| 87 | ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red,bold' | 115 | ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red,bold' |