Improve zsh startup

This commit is contained in:
MangoPig
2026-06-01 16:59:04 +01:00
parent bec96e8456
commit 5b3f5e7698
3 changed files with 47 additions and 12 deletions

View File

@@ -2,15 +2,20 @@
# Zsh Configuration
export ZSH="$HOME/.oh-my-zsh"
export ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
export ZSH_COMPDUMP="${ZSH_CACHE_DIR}/.zcompdump-${HOST}-${ZSH_VERSION}"
mkdir -p "$ZSH_CACHE_DIR"
export DOTZSH_GIT_PLUGIN="$ZSH/plugins/git/git.plugin.zsh"
export DOTZSH_SUDO_PLUGIN="$ZSH/plugins/sudo/sudo.plugin.zsh"
export DOTZSH_RCLONE_PLUGIN="$ZSH/plugins/rclone/rclone.plugin.zsh"
export DOTZSH_AUTOSUGGESTIONS_PLUGIN="$ZSH/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
export DOTZSH_SYNTAX_HIGHLIGHTING_PLUGIN="$ZSH/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh"
# Programming Languages Root
export PROG_DIR="$HOME/.programming"
# Plugins
plugins=(git zsh-syntax-highlighting zsh-autosuggestions sudo rclone)
source $ZSH/oh-my-zsh.sh
# Go and GVM (Black Box)
export GOPATH="$PROG_DIR/go"
export GVM_ROOT="$GOPATH"
@@ -29,7 +34,6 @@ gofmt() { gvm_load gofmt "$@"; }
export NVM_DIR="$PROG_DIR/node"
nvm_load() {
echo "💤 Waking up NVM..."
unset -f nvm node npm npx
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
"$@"
@@ -72,9 +76,13 @@ if [ -d "$RIG_HOME/bin" ]; then
export PATH="$RIG_HOME/bin:$PATH"
fi
is_wsl() {
[ -f /proc/version ] && grep -qEi "(Microsoft|WSL)" /proc/version
}
if [ -n "${WSL_DISTRO_NAME:-}" ] || [ -n "${WSL_INTEROP:-}" ]; then
typeset -gr DOTZSH_IS_WSL=1
elif [ -r /proc/sys/kernel/osrelease ] && grep -qiE '(microsoft|wsl)' /proc/sys/kernel/osrelease 2>/dev/null; then
typeset -gr DOTZSH_IS_WSL=1
else
typeset -gr DOTZSH_IS_WSL=0
fi
# Zoxide
if command -v zoxide >/dev/null 2>&1; then
@@ -89,7 +97,7 @@ fi
export PATH="$HOME/.local/bin:$CARGO_HOME/bin:$GOPATH/bin:$PATH"
# opencode
if is_wsl && command -v openchamber >/dev/null 2>&1 && ! pgrep -f "openchamber.*7891" > /dev/null; then
if [ "$DOTZSH_IS_WSL" -eq 1 ] && command -v openchamber >/dev/null 2>&1 && ! pgrep -f "openchamber.*7891" >/dev/null 2>&1; then
openchamber --port 7891 >/dev/null 2>&1 &!
fi
@@ -101,5 +109,14 @@ fi
# Completion Styling
[ -f ~/.zsh_completion ] && source ~/.zsh_completion
# Plugin Scripts (lighter than loading full Oh My Zsh)
[ -f "$DOTZSH_GIT_PLUGIN" ] && source "$DOTZSH_GIT_PLUGIN"
[ -f "$DOTZSH_SUDO_PLUGIN" ] && source "$DOTZSH_SUDO_PLUGIN"
[ -f "$DOTZSH_RCLONE_PLUGIN" ] && source "$DOTZSH_RCLONE_PLUGIN"
# Prompt Styling
[ -f ~/.zsh_prompt ] && source ~/.zsh_prompt
# Interactive Enhancements
[ -f "$DOTZSH_AUTOSUGGESTIONS_PLUGIN" ] && source "$DOTZSH_AUTOSUGGESTIONS_PLUGIN"
[ -f "$DOTZSH_SYNTAX_HIGHLIGHTING_PLUGIN" ] && source "$DOTZSH_SYNTAX_HIGHLIGHTING_PLUGIN"