Last active 2 weeks ago

Cross-platform Zsh setup scripts and managed dotfiles with Oh My Zsh framework, Starship prompt, aliases, functions, and path configuration.

Revision ee54d6533e788346edac4abf59d993833a2a9d20

README.md Raw

Bash Script Installer for Zsh

The "Bash Script Installer" simplifies the setup of Zsh.

Zsh

Ubuntu

bash -c "$(curl -fsSL https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD/zsh_ubuntu.sh)"

WSL

bash -c "$(curl -fsSL https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD/zsh_wsl.sh)"

MacOS

bash -c "$(curl -fsSL https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD/zsh_macos.sh)"

Configuration

bash -c "$(curl -fsSL https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD/config.sh)"
alias Raw
1# =============================================================================
2# OS-SPECIFIC ALIASES
3# =============================================================================
4if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v apt-get >/dev/null 2>&1; then
5 # Linux Only System update & cleanup
6 alias uu='sudo apt-get update && \
7 sudo apt-get upgrade -y && \
8 sudo apt-get full-upgrade -y && \
9 sudo apt-get autoremove -y && \
10 sudo apt-get autoclean -y && \
11 sudo apt-get clean'
12elif [[ "$OSTYPE" == "darwin"* ]]; then
13 # macOS Only
14 alias flushdns='sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder'
15fi
16
17# =============================================================================
18# UNIVERSAL GIT ALIASES (Fixed: Removed broken "$@" from aliases)
19# =============================================================================
20alias gph='git push'
21alias gco='git checkout'
22alias gbh='git branch'
23alias gmt='git commit'
24alias gpl='git pull'
25alias grb='git rebase'
26alias grt='git reset'
27alias gst='git status'
28alias grmrf='git checkout -- . && git clean -fd'
config.sh Raw
1#!/bin/bash
2set -euo pipefail
3
4# Configuration
5GIST_RAW_BASE="https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD"
6CONFIG_FILES=(
7 ".alias"
8 ".func"
9 ".pathrc"
10 ".sourcerc"
11 ".vimrc"
12 ".zshrc"
13)
14
15echo "Starting configuration download..."
16
17for f in "${CONFIG_FILES[@]}"; do
18 # Remove the leading dot for the URL path
19 remote_name="${f#.}"
20 url="$GIST_RAW_BASE/$remote_name"
21 target="$HOME/$f"
22
23 echo "Downloading $f..."
24
25 # Use -f to fail silently on server errors, -s for silent, -L to follow redirects
26 if curl -fsSL "$url" -o "$target"; then
27 echo "Successfully updated $target"
28 else
29 echo "Error: Failed to download $f from $url" >&2
30 fi
31done
32
33echo "Done! All configuration files have been replaced."
func Raw
1# =============================================================================
2# CUSTOM FUNCTIONS
3# =============================================================================
4
5# -----------------------------------------------------------------------------
6# Function: clip (Cross-platform clipboard)
7# -----------------------------------------------------------------------------
8clip() {
9 local cmd
10 local args=()
11
12 if command -v pbcopy >/dev/null 2>&1; then
13 cmd="pbcopy" # macOS
14 elif grep -qi "microsoft" /proc/version 2>/dev/null && command -v clip.exe >/dev/null 2>&1; then
15 cmd="clip.exe" # WSL
16 elif [ "$XDG_SESSION_TYPE" = "wayland" ] && command -v wl-copy >/dev/null 2>&1; then
17 cmd="wl-copy" # Linux Wayland
18 elif command -v xclip >/dev/null 2>&1; then
19 cmd="xclip" # Linux X11 (Fallback 1)
20 args=("-selection" "clipboard")
21 elif command -v xsel >/dev/null 2>&1; then
22 cmd="xsel" # Linux X11 (Fallback 2)
23 args=("--clipboard" "--input")
24 else
25 printf "Error: No supported clipboard utility found.\n" >&2
26 return 1
27 fi
28
29 if [ $# -gt 0 ]; then
30 if [ -f "$1" ]; then
31 "$cmd" "${args[@]}" < "$1"
32 echo "Copied contents of '$1' to clipboard."
33 else
34 printf "Error: File '%s' not found.\n" "$1" >&2
35 return 1
36 fi
37 else
38 "$cmd" "${args[@]}"
39 fi
40}
41
42# -----------------------------------------------------------------------------
43# Function: open_file (Cross-platform file/directory opener)
44# -----------------------------------------------------------------------------
45open_file() {
46 local target="${1:-.}"
47
48 if [[ "$OSTYPE" == "darwin"* ]]; then
49 command open "$target"
50 elif grep -qi "microsoft" /proc/version 2>/dev/null; then
51 if command -v wslpath >/dev/null 2>&1 && command -v explorer.exe >/dev/null 2>&1; then
52 explorer.exe "$(wslpath -w "$target")"
53 else
54 printf "Error: 'wslpath' or 'explorer.exe' not found.\n" >&2
55 return 1
56 fi
57 elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
58 if command -v xdg-open >/dev/null 2>&1; then
59 xdg-open "$target"
60 else
61 printf "Error: 'xdg-open' not found.\n" >&2
62 return 1
63 fi
64 fi
65}
66alias open='open_file'
67
68# -----------------------------------------------------------------------------
69# Function: clear_history (Supports shell and Claude)
70# -----------------------------------------------------------------------------
71# -----------------------------------------------------------------------------
72# Function: clear_history (Supports shell and Claude)
73# -----------------------------------------------------------------------------
74clear_history() {
75 case "$1" in
76 claude)
77 if [ -d "$HOME/.claude/projects" ]; then
78 # Use 'yes' to skip prompts and -f to ignore non-existent files
79 yes | rm -rf "$HOME/.claude/projects"/*
80 echo "Claude project history/cache cleared."
81 fi
82 ;;
83
84 *)
85 # 1. Truncate the file
86 : > "$HISTFILE"
87
88 # 2. Clear RAM by briefly setting history size to 0
89 local old_histsize=$HISTSIZE
90 HISTSIZE=0
91 HISTSIZE=$old_histsize
92
93 echo "Shell history cleared."
94 ;;
95 esac
96}
97
98# -----------------------------------------------------------------------------
99# Function: claude (Includes --yolo and clear shortcuts)
100# -----------------------------------------------------------------------------
101claude() {
102 # Shortcut for clearing cache
103 if [[ "$1" == "clear" ]]; then
104 clear_history claude
105 return 0
106 fi
107
108 # Check if binary exists
109 if ! whence -p claude >/dev/null 2>&1; then
110 printf "Error: 'claude' CLI is not installed or not in your PATH.\n" >&2
111 return 1
112 fi
113
114 # Handle --yolo mode
115 if [[ "$1" == "--yolo" ]]; then
116 shift
117 command claude --dangerously-skip-permissions "$@"
118 return $?
119 fi
120
121 command claude "$@"
122}
123
124# -----------------------------------------------------------------------------
125# Function: create (Efficiently create file + parent dirs)
126# -----------------------------------------------------------------------------
127create() {
128 if ! command -v install >/dev/null 2>&1; then
129 printf "Error: 'install' coreutil is not available.\n" >&2
130 return 1
131 fi
132
133 if [ $# -eq 0 ]; then
134 printf "Usage: create <file> [file ...]\n" >&2
135 return 2
136 fi
137
138 for p in "$@"; do
139 # Expand tilde manually if shell doesn't
140 [[ "$p" == "~/"* ]] && p="${HOME}/${p#\~/}"
141
142 if [ -z "$p" ] || [ "$p" = "/" ]; then
143 printf "create: refusing to operate on '%s'\n" "$p" >&2
144 continue
145 fi
146
147 if [ -e "$p" ]; then
148 printf "create: '%s' already exists. Skipping.\n" "$p" >&2
149 continue
150 fi
151
152 if install -D /dev/null "$p"; then
153 echo "Created '$p'"
154 fi
155 done
156}
157
158# -----------------------------------------------------------------------------
159# Function: check_port
160# -----------------------------------------------------------------------------
161check_port() {
162 local PORT=$1
163 if [ -z "$PORT" ]; then
164 printf "Usage: check_port <port_number>\n" >&2
165 return 1
166 fi
167
168 if [[ "$OSTYPE" == "darwin"* ]]; then
169 lsof -i :"$PORT" || echo "Port $PORT is FREE"
170 else
171 sudo ss -tulnp | grep ":$PORT " || echo "Port $PORT is FREE"
172 fi
173}
174
175# -----------------------------------------------------------------------------
176# Function: append_path (Adds to session PATH if exists)
177# -----------------------------------------------------------------------------
178append_path() {
179 local dir="$1"
180 if [ -d "$dir" ]; then
181 case ":$PATH:" in
182 *":$dir:"*) ;;
183 *) PATH="$PATH:$dir" ;;
184 esac
185 elif [ "${SUPPRESS_WARNINGS:-0}" -ne 1 ]; then
186 echo "Warning: $dir does not exist." >&2
187 fi
188}
189
190# -----------------------------------------------------------------------------
191# Function: add_path_to_config (Fixed awk/sed injection)
192# -----------------------------------------------------------------------------
193add_path_to_config() {
194 local new_path="$1"
195 local config_file="$HOME/.bashrc"
196 [[ "$SHELL" == *"zsh"* ]] && config_file="$HOME/.zshrc"
197
198 if [ -z "$new_path" ]; then
199 printf "Usage: add_path_to_config <directory>\n" >&2
200 return 1
201 fi
202
203 new_path="${new_path/#\~/$HOME}"
204
205 if [ ! -d "$new_path" ]; then
206 printf "Warning: '%s' does not exist. Add anyway? (y/N) " "$new_path"
207 read -r REPLY
208 [[ ! $REPLY =~ ^[Yy]$ ]] && return 1
209 fi
210
211 # Check if already exists in file
212 if grep -Fq "append_path \"$new_path\"" "$config_file"; then
213 printf "Notice: Already in %s.\n" "$config_file"
214 return 0
215 fi
216
217 # Robust Injection: Use sed to insert before export PATH or just append
218 if grep -q "^export PATH" "$config_file"; then
219 sed -i.bak "/^export PATH/i append_path \"$new_path\"" "$config_file"
220 else
221 echo "append_path \"$new_path\"" >> "$config_file"
222 echo "export PATH" >> "$config_file"
223 fi
224
225 printf "✅ Success: Added to %s\n" "$config_file"
226 append_path "$new_path" && export PATH
227}
pathrc Raw
1# =============================================================================
2# ENVIRONMENT & PATH CONFIGURATION
3# =============================================================================
4
5# 1. Source functions first
6if [[ -f "$HOME/.func" && -r "$HOME/.func" ]]; then
7 source "$HOME/.func"
8fi
9
10# 2. Define Root Variables
11export DOTNET_ROOT="$HOME/.dotnet"
12
13# 3. PATH INITIALIZATION
14# -----------------------------------------------------------------------------
15append_path "$HOME/.local/bin"
16append_path "$DOTNET_ROOT"
17append_path "$DOTNET_ROOT/tools"
18append_path "$HOME/.opencode/bin"
19append_path "$HOME/Flutter/bin"
20
21# macOS specific paths
22if [[ "$OSTYPE" == "darwin"* ]]; then
23 append_path "/Applications/Espanso.app/Contents/MacOS"
24fi
25
26# Finalize PATH
27export PATH
sourcerc Raw
1# =============================================================================
2# FILE: ~/.sourcerc
3# Description: Initializes third-party package managers and Oh My Zsh.
4# =============================================================================
5
6# Source the custom environment setup file if it exists and is not empty
7if [[ -f "$HOME/.local/bin/env" && -r "$HOME/.local/bin/env" ]]; then
8 source "$HOME/.local/bin/env"
9fi
10
11# Source the SDKMAN initialization script if it exists and is not empty
12if [[ -f "$HOME/.sdkman/bin/sdkman-init.sh" && -r "$HOME/.sdkman/bin/sdkman-init.sh" ]]; then
13 source "$HOME/.sdkman/bin/sdkman-init.sh"
14fi
15
16# Source the NVM initialization script if it exists and is not empty
17if [[ -f "$HOME/.nvm/nvm.sh" && -r "$HOME/.nvm/nvm.sh" ]]; then
18 source "$HOME/.nvm/nvm.sh"
19fi
20
21# =============================================================================
22# CLAUDE CODE / AI GATEWAY
23# =============================================================================
24export ANTHROPIC_BASE_URL="https://gateway.ai.cloudflare.com/v1/9a71825e3842e918e0dff9ad84f50484/claude-code-gateway/anthropic"
25
26# =============================================================================
27# OH MY ZSH
28# =============================================================================
29if [[ -f "$HOME/.oh-my-zsh/oh-my-zsh.sh" && -r "$HOME/.oh-my-zsh/oh-my-zsh.sh" ]]; then
30 source "$HOME/.oh-my-zsh/oh-my-zsh.sh"
31else
32 echo "Warning: Oh My Zsh not found or is empty."
33fi
34
35# =============================================================================
36# GOOGLE CLOUD SDK
37# =============================================================================
38if [[ -f "$HOME/google-cloud-sdk/path.zsh.inc" ]]; then
39 source "$HOME/google-cloud-sdk/path.zsh.inc"
40fi
41
42if [[ -f "$HOME/google-cloud-sdk/completion.zsh.inc" ]]; then
43 source "$HOME/google-cloud-sdk/completion.zsh.inc"
44fi
45
46# =============================================================================
47# NVM (Node Version Manager)
48# =============================================================================
49export NVM_DIR="$HOME/.nvm"
50
51[[ -f "$NVM_DIR/nvm.sh" && -r "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh"
52[[ -f "$NVM_DIR/bash_completion" && -r "$NVM_DIR/bash_completion" ]] && \. "$NVM_DIR/bash_completion"
vimrc Raw
1" Enable line numbers
2set number
3
4" Enable relative line numbers
5set relativenumber
6
7" Enable syntax highlighting
8syntax on
9
10" Set colorscheme
11colorscheme slate
12
13" Enable file type detection and plugins
14filetype plugin indent on
15
16" Set the tab width to 4 spaces
17set tabstop=4
18set shiftwidth=4
19set expandtab
20
21" Enable auto-indentation
22set autoindent
23set smartindent
24
25" Highlight current line
26set cursorline
27
28" Show matching parentheses
29set showmatch
30
31" Enable line wrapping
32set wrap
33
34" Enable mouse support
35set mouse=a
36
37" Enable clipboard access
38set clipboard=unnamedplus
39
40" Disable swap file
41set noswapfile
42
43" Enable incremental search
44set incsearch
45
46" Ignore case in search
47set ignorecase
48
49" Override ignorecase if search contains capital letters
50set smartcase
51
52" Display line and column number of the cursor position
53set ruler
54
55" Set the status line at the bottom
56set laststatus=2
57
58" Show command in bottom bar
59set showcmd
60
61" Set command height
62set cmdheight=2
63
64" Set history lines
65set history=1000
66
67" Disable backup file
68set nobackup
69
70" Enable persistent undo
71set undofile
72
73" Set maximum number of undo levels
74set undolevels=1000
75
76" Set undo directory
77if has("persistent_undo")
78 silent !mkdir ~/.vim/undodir > /dev/null 2>&1
79 set undodir=~/.vim/undodir
80endif
81
82" Set search highlighting
83set hlsearch
84
85" Enable visual bell
86set visualbell
87
88" Set default file encoding
89set encoding=utf-8
90
91" Set the leader key to space
92let mapleader = " "
93
94" Map <Leader>w to save the file
95nnoremap <Leader>w :w<CR>
96
97" Map <Leader>q to quit
98nnoremap <Leader>q :q<CR>
99
100" Map <Leader>x to save and quit
101nnoremap <Leader>x :wq<CR>
102
103" Enable folding
104set foldmethod=syntax
105set foldlevelstart=99
106
107" Enable line wrapping at 80 characters
108set textwidth=80
109set colorcolumn=80
110
111" Add some basic key mappings
112" Map jj to escape insert mode
113inoremap jj <Esc>
114
115" Map <Leader>n to toggle line numbers
116nnoremap <Leader>n :set number!<CR>
117
118" Map <Leader>r to toggle relative line numbers
119nnoremap <Leader>r :set relativenumber!<CR>
120
121" Configure plugins (if you use a plugin manager like vim-plug)
122" Example with vim-plug:
123" call plug#begin('~/.vim/plugged')
124" Plug 'tpope/vim-sensible'
125" Plug 'preservim/nerdtree'
126" Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
127" Plug 'airblade/vim-gitgutter'
128" call plug#end()
129
130" NERDTree key mappings
131" nnoremap <C-n> :NERDTreeToggle<CR>
132
133" Enable automatic hard wrapping at textwidth (80 chars)
134set formatoptions+=t " Auto-wrap text using textwidth
135set formatoptions+=c " Auto-wrap comments using textwidth
136set formatoptions+=r " Continue comments when pressing Enter
137set formatoptions+=o " Continue comments when using 'o' or 'O'
138set formatoptions+=q " Allow formatting of comments with 'gq'
139set formatoptions+=n " Recognize numbered lists
140set formatoptions+=l " Don't break lines that were already long
141
142" Enable syntax highlighting
143syntax on
144
145" Increase memory limit for complex syntax parsing (Prevents E363)
146set maxmempattern=20000
zsh_macos.sh Raw
1#!/bin/bash
2set -euo pipefail
3
4# =============================
5# COLORS & LOGGING
6# =============================
7RED='\033[0;31m'
8GREEN='\033[0;32m'
9YELLOW='\033[1;33m'
10BLUE='\033[0;34m'
11NC='\033[0m'
12
13log() { echo -e "${BLUE}[INFO]${NC} $*"; }
14ok() { echo -e "${GREEN}[OK]${NC} $*"; }
15warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
16err() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
17
18# =============================
19# CONFIG
20# =============================
21GIST_RAW_BASE="https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD"
22
23CONFIG_FILES=(
24 ".alias"
25 ".func"
26 ".pathrc"
27 ".sourcerc"
28 ".vimrc"
29 ".zshrc"
30)
31
32# =============================
33# REQUIREMENTS
34# =============================
35check_requirements() {
36 if [[ $EUID -eq 0 ]]; then
37 err "Do not run as root on macOS"
38 exit 1
39 fi
40}
41
42# =============================
43# INSTALLATION FUNCTIONS
44# =============================
45install_oh_my_zsh() {
46 if [[ -d "$HOME/.oh-my-zsh" ]]; then
47 ok "Oh My Zsh already installed"
48 return
49 fi
50
51 log "Installing Oh My Zsh..."
52 RUNZSH=no CHSH=no KEEP_ZSHRC=yes \
53 sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
54 ok "Oh My Zsh installed"
55}
56
57install_plugins() {
58 log "Installing plugins..."
59 local dir="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins"
60 mkdir -p "$dir"
61
62 [[ -d "$dir/zsh-autosuggestions" ]] || \
63 git clone https://github.com/zsh-users/zsh-autosuggestions "$dir/zsh-autosuggestions"
64
65 [[ -d "$dir/zsh-syntax-highlighting" ]] || \
66 git clone https://github.com/zsh-users/zsh-syntax-highlighting "$dir/zsh-syntax-highlighting"
67
68 ok "Plugins installed"
69}
70
71install_spaceship_theme() {
72 log "Installing Spaceship theme..."
73 local themes="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes"
74 local dir="$themes/spaceship-prompt"
75
76 mkdir -p "$themes"
77 [[ -d "$dir" ]] || \
78 git clone https://github.com/spaceship-prompt/spaceship-prompt.git "$dir" --depth=1
79
80 ln -sf "$dir/spaceship.zsh-theme" "$themes/spaceship.zsh-theme"
81 ok "Spaceship theme installed"
82}
83
84install_starship_theme() {
85 if command -v starship >/dev/null 2>&1; then
86 ok "Starship already installed"
87 return
88 fi
89
90 if command -v brew >/dev/null 2>&1; then
91 log "Installing Starship with Homebrew..."
92 brew install starship
93 else
94 log "Installing Starship..."
95 mkdir -p "$HOME/.local/bin"
96 curl -fsSL https://starship.rs/install.sh | sh -s -- -y -b "$HOME/.local/bin"
97 fi
98
99 ok "Starship installed"
100}
101
102install_theme() {
103 local choice="${1:-}"
104 local selected_theme
105
106 if [[ -z "$choice" ]]; then
107 echo "Select prompt theme:"
108 echo " 1) Spaceship"
109 echo " 2) Starship"
110 read -r -p "Select theme [1-2]: " choice
111 fi
112
113 case "$(printf '%s' "$choice" | tr '[:upper:]' '[:lower:]')" in
114 1|spaceship) selected_theme="spaceship" ;;
115 2|starship) selected_theme="starship" ;;
116 *) warn "Invalid theme selection: $choice"; return 1 ;;
117 esac
118
119 case "$selected_theme" in
120 spaceship) install_spaceship_theme ;;
121 starship) install_starship_theme ;;
122 esac
123
124 printf "%s\n" "$selected_theme" > "$HOME/.zsh_theme"
125 ok "Theme selected: $selected_theme"
126}
127
128download_configs() {
129 log "Downloading custom config files..."
130 local backup="$HOME/.config_backup_$(date +%Y%m%d_%H%M%S)"
131 mkdir -p "$backup"
132
133 for f in "${CONFIG_FILES[@]}"; do
134 # Strip the leading dot for the download URL
135 local remote_file="${f#.}"
136 local url="$GIST_RAW_BASE/$remote_file"
137 local target="$HOME/$f"
138 local tmp="${target}.tmp.$$"
139
140 if [[ -f "$target" ]]; then
141 cp "$target" "$backup/"
142 fi
143
144 log "Fetching $remote_file -> $f ..."
145 if curl -fsSL "$url" -o "$tmp"; then
146 mv "$tmp" "$target"
147 else
148 rm -f "$tmp"
149 warn "Failed to download $remote_file"
150 fi
151 done
152
153 ok "Configs downloaded (Backup at $backup)"
154}
155
156update_zshrc() {
157 local zshrc="$HOME/.zshrc"
158 log "Checking .zshrc..."
159
160 if [[ ! -f "$zshrc" ]]; then
161 warn ".zshrc not found. Run option 5 first."
162 return 1
163 fi
164
165 ok ".zshrc already comes from the managed gist."
166 ok "Load order is built in: .sourcerc -> .func -> .pathrc -> .alias"
167}
168
169switch_shell() {
170 log "Starting Zsh session..."
171 echo -e "${YELLOW}Type 'exit' to return to this installer menu.${NC}"
172 echo "----------------------------------------"
173 zsh -l
174 echo "----------------------------------------"
175 ok "Returned from Zsh session"
176}
177
178# =============================
179# INTERACTIVE MENU
180# =============================
181show_menu() {
182 echo "==========================================="
183 echo "macOS Zsh Setup - Choose what to do"
184 echo "==========================================="
185 echo " 0) Run ALL steps (1-7)"
186 echo " 1) Install Oh My Zsh"
187 echo " 2) Install plugins (autosuggestions, syntax highlighting)"
188 echo " 3) Install/select prompt theme (Spaceship or Starship)"
189 echo " 4) Download custom configs (~/.alias, .func, .vimrc, etc.)"
190 echo " 5) Check ~/.zshrc load order"
191 echo " 6) Switch to Zsh (Temporary Sub-shell)"
192 echo " 7) Quit"
193 echo "==========================================="
194}
195
196run_choices() {
197 local input
198 read -p "Select: " input
199 input="${input//,/ }"
200
201 local -a to_run=()
202 local -a to_exclude=()
203
204 for item in $input; do
205 if [[ "$item" == !* ]]; then
206 to_exclude+=("${item:1}")
207 elif [[ "$item" == "0" ]]; then
208 to_run+=(1 2 3 4 5 6)
209 else
210 to_run+=("$item")
211 fi
212 done
213
214 if [[ ${#to_run[@]} -gt 0 ]]; then
215 for choice in "${to_run[@]}"; do
216 local skip=false
217
218 if [[ ${#to_exclude[@]} -gt 0 ]]; then
219 for ex in "${to_exclude[@]}"; do
220 if [[ "$choice" == "$ex" ]]; then
221 skip=true
222 break
223 fi
224 done
225 fi
226
227 $skip && continue
228
229 case "$choice" in
230 1) install_oh_my_zsh ;;
231 2) install_plugins ;;
232 3) install_theme ;;
233 4) download_configs ;;
234 5) update_zshrc ;;
235 6) switch_shell ;;
236 7) exit 0 ;;
237 *) warn "Skipping invalid option: $choice" ;;
238 esac
239 echo
240 done
241 fi
242}
243
244# =============================
245# MAIN
246# =============================
247main() {
248 check_requirements
249 while true; do
250 show_menu
251 run_choices
252 read -p "Do you want to run more options? (y/n): " again
253 [[ "$again" =~ ^[Yy]$ ]] || break
254 done
255 ok "macOS configuration complete!"
256}
257
258main "$@"
259
zsh_ubuntu.sh Raw
1#!/bin/bash
2set -euo pipefail
3
4# =============================
5# COLORS & LOGGING
6# =============================
7RED='\033[0;31m'
8GREEN='\033[0;32m'
9YELLOW='\033[1;33m'
10BLUE='\033[0;34m'
11NC='\033[0m'
12
13log() { echo -e "${BLUE}[INFO]${NC} $*"; }
14ok() { echo -e "${GREEN}[OK]${NC} $*"; }
15warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
16err() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
17
18# =============================
19# FLAGS & CONFIG
20# =============================
21SKIP_PACKAGES=false
22SKIP_SHELL_CHANGE=false
23INSTALL_HOMEBREW=false
24
25GIST_RAW_BASE="https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD"
26CONFIG_FILES=(
27 ".alias"
28 ".func"
29 ".pathrc"
30 ".sourcerc"
31 ".vimrc"
32 ".zshrc"
33)
34
35# =============================
36# OS DETECTION
37# =============================
38detect_os() {
39 if [ -f /etc/os-release ]; then
40 . /etc/os-release
41 echo "$ID"
42 else
43 echo "unknown"
44 fi
45}
46
47# =============================
48# REQUIREMENTS
49# =============================
50check_requirements() {
51 if [[ $EUID -eq 0 ]]; then
52 err "Do not run as root"
53 exit 1
54 fi
55 if ! command -v sudo >/dev/null 2>&1; then
56 err "sudo required"
57 exit 1
58 fi
59}
60
61# =============================
62# INSTALLATION FUNCTIONS
63# =============================
64update_system() {
65 $SKIP_PACKAGES && return
66 log "Updating system..."
67 sudo apt-get update -y
68 sudo apt-get upgrade -y
69 ok "System updated"
70}
71
72install_packages() {
73 $SKIP_PACKAGES && return
74 log "Installing core packages..."
75 sudo apt-get install -y \
76 zsh git vim curl wget unzip zip build-essential xz-utils
77 ok "Packages installed"
78}
79
80set_timezone() {
81 log "Setting timezone to Asia/Singapore..."
82 sudo timedatectl set-timezone Asia/Singapore
83 ok "Timezone set to Asia/Singapore"
84}
85
86install_homebrew() {
87 ! $INSTALL_HOMEBREW && return
88 command -v brew >/dev/null 2>&1 && ok "Homebrew already installed" && return
89 log "Installing Homebrew..."
90 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
91 ok "Homebrew installed"
92}
93
94configure_shell() {
95 $SKIP_SHELL_CHANGE && return
96 log "Changing default shell to zsh..."
97 local zsh_path
98 zsh_path="$(command -v zsh)"
99 grep -qx "$zsh_path" /etc/shells || echo "$zsh_path" | sudo tee -a /etc/shells >/dev/null
100 chsh -s "$zsh_path"
101 ok "Shell changed (requires logout/login to take effect)"
102}
103
104install_oh_my_zsh() {
105 [[ -d "$HOME/.oh-my-zsh" ]] && ok "Oh My Zsh already installed" && return
106 log "Installing Oh My Zsh..."
107 RUNZSH=no CHSH=no KEEP_ZSHRC=yes \
108 sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
109 ok "Oh My Zsh installed"
110}
111
112install_plugins() {
113 log "Installing plugins..."
114 local dir="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins"
115 mkdir -p "$dir"
116 [[ -d "$dir/zsh-autosuggestions" ]] || git clone https://github.com/zsh-users/zsh-autosuggestions "$dir/zsh-autosuggestions"
117 [[ -d "$dir/zsh-syntax-highlighting" ]] || git clone https://github.com/zsh-users/zsh-syntax-highlighting "$dir/zsh-syntax-highlighting"
118 ok "Plugins installed"
119}
120
121install_spaceship_theme() {
122 log "Installing Spaceship theme..."
123 local themes="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes"
124 local dir="$themes/spaceship-prompt"
125 mkdir -p "$themes"
126 [[ -d "$dir" ]] || git clone https://github.com/spaceship-prompt/spaceship-prompt.git "$dir" --depth=1
127 ln -sf "$dir/spaceship.zsh-theme" "$themes/spaceship.zsh-theme"
128 ok "Spaceship theme installed"
129}
130
131install_starship_theme() {
132 if command -v starship >/dev/null 2>&1; then
133 ok "Starship already installed"
134 return
135 fi
136
137 if command -v brew >/dev/null 2>&1; then
138 log "Installing Starship with Homebrew..."
139 brew install starship
140 else
141 log "Installing Starship..."
142 mkdir -p "$HOME/.local/bin"
143 curl -fsSL https://starship.rs/install.sh | sh -s -- -y -b "$HOME/.local/bin"
144 fi
145
146 ok "Starship installed"
147}
148
149install_theme() {
150 local choice="${1:-}"
151 local selected_theme
152
153 if [[ -z "$choice" ]]; then
154 echo "Select prompt theme:"
155 echo " 1) Spaceship"
156 echo " 2) Starship"
157 read -r -p "Select theme [1-2]: " choice
158 fi
159
160 case "$(printf '%s' "$choice" | tr '[:upper:]' '[:lower:]')" in
161 1|spaceship) selected_theme="spaceship" ;;
162 2|starship) selected_theme="starship" ;;
163 *) warn "Invalid theme selection: $choice"; return 1 ;;
164 esac
165
166 case "$selected_theme" in
167 spaceship) install_spaceship_theme ;;
168 starship) install_starship_theme ;;
169 esac
170
171 printf "%s\n" "$selected_theme" > "$HOME/.zsh_theme"
172 ok "Theme selected: $selected_theme"
173}
174
175download_configs() {
176 log "Downloading custom config files..."
177 local backup="$HOME/.config_backup_$(date +%Y%m%d_%H%M%S)"
178 mkdir -p "$backup"
179
180 for f in "${CONFIG_FILES[@]}"; do
181 # Strip the leading dot for the download URL
182 local remote_file="${f#.}"
183 local url="$GIST_RAW_BASE/$remote_file"
184 local target="$HOME/$f"
185 local tmp="${target}.tmp.$$"
186
187 if [[ -f "$target" ]]; then
188 cp "$target" "$backup/"
189 fi
190
191 log "Fetching $remote_file -> $f ..."
192 if curl -fsSL "$url" -o "$tmp"; then
193 mv "$tmp" "$target"
194 else
195 rm -f "$tmp"
196 warn "Failed to download $remote_file"
197 fi
198 done
199
200 ok "Configs downloaded (Backup at $backup)"
201}
202
203update_zshrc() {
204 local zshrc="$HOME/.zshrc"
205 log "Checking .zshrc..."
206
207 if [[ ! -f "$zshrc" ]]; then
208 warn ".zshrc not found. Run option 9 first."
209 return 1
210 fi
211
212 ok ".zshrc already comes from the managed gist."
213 ok "Load order is built in: .sourcerc -> .func -> .pathrc -> .alias"
214}
215
216switch_shell() {
217 log "Starting Zsh session..."
218 echo -e "${YELLOW}Type 'exit' to return to this installer menu.${NC}"
219 echo "----------------------------------------"
220 zsh -l
221 echo "----------------------------------------"
222 ok "Returned from Zsh session"
223}
224
225# =============================
226# INTERACTIVE MENU
227# =============================
228show_menu() {
229 echo "==========================================="
230 echo "Zsh Installer - Choose what to do"
231 echo "==========================================="
232 echo " 0) Run ALL steps (1-11)"
233 echo " 1) Update system packages"
234 echo " 2) Install core packages (zsh, git, vim, etc.)"
235 echo " 3) Set Timezone (Asia/Singapore)"
236 echo " 4) Install Homebrew"
237 echo " 5) Configure shell (chsh - sets default shell)"
238 echo " 6) Install Oh My Zsh"
239 echo " 7) Install plugins (autosuggestions, syntax highlighting)"
240 echo " 8) Install/select prompt theme (Spaceship or Starship)"
241 echo " 9) Download custom configs (~/.alias, .vimrc, etc.)"
242 echo "10) Check ~/.zshrc load order"
243 echo "11) Switch to Zsh (Temporary Sub-shell)"
244 echo "12) Quit"
245 echo "==========================================="
246}
247
248run_choices() {
249 local input
250 read -p "Select: " input
251 input="${input//,/ }"
252
253 local -a to_run=()
254 local -a to_exclude=()
255
256 for item in $input; do
257 if [[ "$item" == !* ]]; then
258 to_exclude+=("${item:1}")
259 elif [[ "$item" == "0" ]]; then
260 to_run+=(1 2 3 4 5 6 7 8 9 10 11)
261 else
262 to_run+=("$item")
263 fi
264 done
265
266 for choice in "${to_run[@]}"; do
267 local skip=false
268
269 for ex in "${to_exclude[@]}"; do
270 if [[ "$choice" == "$ex" ]]; then
271 skip=true
272 break
273 fi
274 done
275
276 $skip && continue
277
278 case "$choice" in
279 1) update_system ;;
280 2) install_packages ;;
281 3) set_timezone ;;
282 4) install_homebrew ;;
283 5) configure_shell ;;
284 6) install_oh_my_zsh ;;
285 7) install_plugins ;;
286 8) install_theme ;;
287 9) download_configs ;;
288 10) update_zshrc ;;
289 11) switch_shell ;;
290 12) log "Exiting..."; exit 0 ;;
291 *) warn "Skipping invalid option: $choice" ;;
292 esac
293 echo
294 done
295}
296
297# =============================
298# MAIN
299# =============================
300main() {
301 check_requirements
302 while true; do
303 show_menu
304 run_choices
305 read -p "Do you want to run more options? (y/n): " again
306 [[ "$again" =~ ^[Yy]$ ]] || break
307 done
308 ok "Zsh installation/configuration complete!"
309}
310
311main "$@"
312
zsh_wsl.sh Raw
1#!/bin/bash
2set -euo pipefail
3
4# =============================
5# COLORS & LOGGING
6# =============================
7RED='\033[0;31m'
8GREEN='\033[0;32m'
9YELLOW='\033[1;33m'
10BLUE='\033[0;34m'
11NC='\033[0m'
12
13log() { echo -e "${BLUE}[INFO]${NC} $*"; }
14ok() { echo -e "${GREEN}[OK]${NC} $*"; }
15warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
16err() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
17
18# =============================
19# FLAGS & CONFIG
20# =============================
21SKIP_PACKAGES=false
22SKIP_SHELL_CHANGE=false
23INSTALL_HOMEBREW=false
24
25GIST_RAW_BASE="https://opengist.rmrf.online/weehong/f0d940c3c1214bf5b7996195199fdc09/raw/HEAD"
26CONFIG_FILES=(
27 ".alias"
28 ".func"
29 ".pathrc"
30 ".sourcerc"
31 ".vimrc"
32 ".zshrc"
33)
34
35# =============================
36# PLATFORM DETECTION
37# =============================
38detect_os() {
39 if [ -f /etc/os-release ]; then
40 . /etc/os-release
41 echo "$ID"
42 else
43 echo "unknown"
44 fi
45}
46
47is_wsl() {
48 grep -qi "microsoft" /proc/version 2>/dev/null
49}
50
51# =============================
52# REQUIREMENTS
53# =============================
54check_requirements() {
55 if [[ $EUID -eq 0 ]]; then
56 err "Do not run as root"
57 exit 1
58 fi
59 if ! command -v sudo >/dev/null 2>&1; then
60 err "sudo required"
61 exit 1
62 fi
63 if ! is_wsl; then
64 err "This installer is intended for WSL"
65 exit 1
66 fi
67}
68
69# =============================
70# INSTALLATION FUNCTIONS
71# =============================
72update_system() {
73 $SKIP_PACKAGES && return
74 log "Updating system..."
75 sudo apt-get update -y
76 sudo apt-get upgrade -y
77 ok "System updated"
78}
79
80install_packages() {
81 $SKIP_PACKAGES && return
82 log "Installing core packages..."
83 sudo apt-get install -y \
84 zsh git vim curl wget unzip zip build-essential xz-utils
85 ok "Packages installed"
86}
87
88set_timezone() {
89 log "Checking timezone configuration..."
90 if command -v timedatectl >/dev/null 2>&1 && timedatectl status >/dev/null 2>&1; then
91 sudo timedatectl set-timezone Asia/Singapore
92 ok "Timezone set to Asia/Singapore"
93 return
94 fi
95
96 warn "Skipping timezone change: timedatectl is not available in this WSL environment"
97}
98
99install_homebrew() {
100 ! $INSTALL_HOMEBREW && return
101 command -v brew >/dev/null 2>&1 && ok "Homebrew already installed" && return
102 log "Installing Homebrew..."
103 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
104 ok "Homebrew installed"
105}
106
107configure_shell() {
108 $SKIP_SHELL_CHANGE && return
109 log "Changing default shell to zsh..."
110 local zsh_path
111 zsh_path="$(command -v zsh)"
112 grep -qx "$zsh_path" /etc/shells || echo "$zsh_path" | sudo tee -a /etc/shells >/dev/null
113 chsh -s "$zsh_path"
114 ok "Shell changed (open a new WSL session for it to take effect)"
115}
116
117install_oh_my_zsh() {
118 [[ -d "$HOME/.oh-my-zsh" ]] && ok "Oh My Zsh already installed" && return
119 log "Installing Oh My Zsh..."
120 RUNZSH=no CHSH=no KEEP_ZSHRC=yes \
121 sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
122 ok "Oh My Zsh installed"
123}
124
125install_plugins() {
126 log "Installing plugins..."
127 local dir="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins"
128 mkdir -p "$dir"
129 [[ -d "$dir/zsh-autosuggestions" ]] || git clone https://github.com/zsh-users/zsh-autosuggestions "$dir/zsh-autosuggestions"
130 [[ -d "$dir/zsh-syntax-highlighting" ]] || git clone https://github.com/zsh-users/zsh-syntax-highlighting "$dir/zsh-syntax-highlighting"
131 ok "Plugins installed"
132}
133
134install_spaceship_theme() {
135 log "Installing Spaceship theme..."
136 local themes="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes"
137 local dir="$themes/spaceship-prompt"
138 mkdir -p "$themes"
139 [[ -d "$dir" ]] || git clone https://github.com/spaceship-prompt/spaceship-prompt.git "$dir" --depth=1
140 ln -sf "$dir/spaceship.zsh-theme" "$themes/spaceship.zsh-theme"
141 ok "Spaceship theme installed"
142}
143
144install_starship_theme() {
145 if command -v starship >/dev/null 2>&1; then
146 ok "Starship already installed"
147 return
148 fi
149
150 if command -v brew >/dev/null 2>&1; then
151 log "Installing Starship with Homebrew..."
152 brew install starship
153 else
154 log "Installing Starship..."
155 mkdir -p "$HOME/.local/bin"
156 curl -fsSL https://starship.rs/install.sh | sh -s -- -y -b "$HOME/.local/bin"
157 fi
158
159 ok "Starship installed"
160}
161
162install_theme() {
163 local choice="${1:-}"
164 local selected_theme
165
166 if [[ -z "$choice" ]]; then
167 echo "Select prompt theme:"
168 echo " 1) Spaceship"
169 echo " 2) Starship"
170 read -r -p "Select theme [1-2]: " choice
171 fi
172
173 case "$(printf '%s' "$choice" | tr '[:upper:]' '[:lower:]')" in
174 1|spaceship) selected_theme="spaceship" ;;
175 2|starship) selected_theme="starship" ;;
176 *) warn "Invalid theme selection: $choice"; return 1 ;;
177 esac
178
179 case "$selected_theme" in
180 spaceship) install_spaceship_theme ;;
181 starship) install_starship_theme ;;
182 esac
183
184 printf "%s\n" "$selected_theme" > "$HOME/.zsh_theme"
185 ok "Theme selected: $selected_theme"
186}
187
188download_configs() {
189 log "Downloading custom config files..."
190 local backup="$HOME/.config_backup_$(date +%Y%m%d_%H%M%S)"
191 mkdir -p "$backup"
192
193 for f in "${CONFIG_FILES[@]}"; do
194 # Strip the leading dot for the download URL
195 local remote_file="${f#.}"
196 local url="$GIST_RAW_BASE/$remote_file"
197 local target="$HOME/$f"
198 local tmp="${target}.tmp.$$"
199
200 if [[ -f "$target" ]]; then
201 cp "$target" "$backup/"
202 fi
203
204 log "Fetching $remote_file -> $f ..."
205 if curl -fsSL "$url" -o "$tmp"; then
206 mv "$tmp" "$target"
207 else
208 rm -f "$tmp"
209 warn "Failed to download $remote_file"
210 fi
211 done
212
213 ok "Configs downloaded (Backup at $backup)"
214}
215
216update_zshrc() {
217 local zshrc="$HOME/.zshrc"
218 log "Checking .zshrc..."
219
220 if [[ ! -f "$zshrc" ]]; then
221 warn ".zshrc not found. Run option 9 first."
222 return 1
223 fi
224
225 ok ".zshrc already comes from the managed gist."
226 ok "Load order is built in: .sourcerc -> .func -> .pathrc -> .alias"
227}
228
229switch_shell() {
230 log "Starting Zsh session..."
231 echo -e "${YELLOW}Type 'exit' to return to this installer menu.${NC}"
232 echo "----------------------------------------"
233 zsh -l
234 echo "----------------------------------------"
235 ok "Returned from Zsh session"
236}
237
238# =============================
239# INTERACTIVE MENU
240# =============================
241show_menu() {
242 echo "==========================================="
243 echo "WSL Zsh Installer - Choose what to do"
244 echo "==========================================="
245 echo " 0) Run ALL steps (1-11)"
246 echo " 1) Update system packages"
247 echo " 2) Install core packages (zsh, git, vim, etc.)"
248 echo " 3) Set Timezone (best effort)"
249 echo " 4) Install Homebrew"
250 echo " 5) Configure shell (chsh - sets default shell)"
251 echo " 6) Install Oh My Zsh"
252 echo " 7) Install plugins (autosuggestions, syntax highlighting)"
253 echo " 8) Install/select prompt theme (Spaceship or Starship)"
254 echo " 9) Download custom configs (~/.alias, .vimrc, etc.)"
255 echo "10) Check ~/.zshrc load order"
256 echo "11) Switch to Zsh (Temporary Sub-shell)"
257 echo "12) Quit"
258 echo "==========================================="
259}
260
261run_choices() {
262 local input
263 read -p "Select: " input
264 input="${input//,/ }"
265
266 local -a to_run=()
267 local -a to_exclude=()
268
269 for item in $input; do
270 if [[ "$item" == !* ]]; then
271 to_exclude+=("${item:1}")
272 elif [[ "$item" == "0" ]]; then
273 to_run+=(1 2 3 4 5 6 7 8 9 10 11)
274 else
275 to_run+=("$item")
276 fi
277 done
278
279 for choice in "${to_run[@]}"; do
280 local skip=false
281
282 for ex in "${to_exclude[@]}"; do
283 if [[ "$choice" == "$ex" ]]; then
284 skip=true
285 break
286 fi
287 done
288
289 $skip && continue
290
291 case "$choice" in
292 1) update_system ;;
293 2) install_packages ;;
294 3) set_timezone ;;
295 4) install_homebrew ;;
296 5) configure_shell ;;
297 6) install_oh_my_zsh ;;
298 7) install_plugins ;;
299 8) install_theme ;;
300 9) download_configs ;;
301 10) update_zshrc ;;
302 11) switch_shell ;;
303 12) log "Exiting..."; exit 0 ;;
304 *) warn "Skipping invalid option: $choice" ;;
305 esac
306 echo
307 done
308}
309
310# =============================
311# MAIN
312# =============================
313main() {
314 check_requirements
315 while true; do
316 show_menu
317 run_choices
318 read -p "Do you want to run more options? (y/n): " again
319 [[ "$again" =~ ^[Yy]$ ]] || break
320 done
321 ok "WSL Zsh installation/configuration complete!"
322}
323
324main "$@"
325
zshrc Raw
1# =============================================================================
2# 1. ZSH THEME & PLUGINS (Must be defined before Oh My Zsh loads)
3# =============================================================================
4export ZSH="$HOME/.oh-my-zsh"
5
6source_if_readable() {
7 local file="$1"
8 if [[ -f "$file" && -r "$file" ]]; then
9 source "$file"
10 fi
11}
12
13ZSH_THEME_CHOICE="${ZSH_THEME_CHOICE:-}"
14if [[ -z "$ZSH_THEME_CHOICE" && -f "$HOME/.zsh_theme" ]]; then
15 ZSH_THEME_CHOICE="$(<"$HOME/.zsh_theme")"
16fi
17ZSH_THEME_CHOICE="${ZSH_THEME_CHOICE:-spaceship}"
18
19case "$ZSH_THEME_CHOICE" in
20 starship)
21 ZSH_THEME=""
22 ;;
23 spaceship|*)
24 ZSH_THEME="spaceship"
25
26 SPACESHIP_PROMPT_ORDER=(
27 time # Time stamps section
28 user # Username section
29 dir # Current directory section
30 git # Git section (git_branch + git_status)
31 node # Node.js section
32 dotnet # .NET section
33 java # Java section
34 kotlin # Kotlin section
35 ruby # Ruby section
36 xcode # Xcode section
37 swift # Swift section
38 golang # Go section
39 docker # Docker section
40 venv # virtualenv section
41 line_sep # Line break
42 char # Prompt character
43 )
44
45 SPACESHIP_USER_SHOW=always
46 SPACESHIP_PROMPT_SEPARATE_LINE=true
47 SPACESHIP_PROMPT_ADD_NEWLINE=true
48 SPACESHIP_CHAR_SYMBOL="❯"
49 SPACESHIP_CHAR_SUFFIX=" "
50 SPACESHIP_DOCKER_CONTEXT_SHOW=false
51
52 if [[ $(uname) == "Darwin" ]]; then
53 #  is the Apple logo in Nerd Fonts
54 SPACESHIP_USER_SUFFIX="%F{cyan} [  ]%f "
55 elif [[ $(uname) == "Linux" ]]; then
56 #  is the Ubuntu logo in Nerd Fonts
57 SPACESHIP_USER_SUFFIX="%F{yellow} [  ]%f "
58 else
59 SPACESHIP_USER_SUFFIX=" "
60 fi
61 ;;
62esac
63
64plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
65
66# Initialize Oh My Zsh (Crucial for themes and plugins to work)
67source_if_readable "$ZSH/oh-my-zsh.sh"
68
69# =============================================================================
70# 2. THIRD-PARTY INITIALIZATION (SDKMAN, NVM, Oh My Zsh)
71# =============================================================================
72source_if_readable "$HOME/.sourcerc"
73
74# =============================================================================
75# 3. CUSTOM OVERRIDES (Functions must load before Path Management)
76# =============================================================================
77source_if_readable "$HOME/.func"
78
79# =============================================================================
80# 4. PATH MANAGEMENT (Relies on append_path from .func)
81# =============================================================================
82source_if_readable "$HOME/.pathrc"
83
84# =============================================================================
85# 5. ALIASES (Loaded dead last so YOUR code always wins over Oh My Zsh)
86# =============================================================================
87source_if_readable "$HOME/.alias"
88
89if [[ "$ZSH_THEME_CHOICE" == "starship" ]]; then
90 if command -v starship >/dev/null 2>&1; then
91 eval "$(starship init zsh)"
92 else
93 echo "Warning: Starship selected but starship is not installed."
94 fi
95fi
96