Zsh prompt (#67)
* feat: initial prompt pass * fix: code quality * fix: perf * fix: layout * fix: cleanup * fix: perf * feat: nvm/pyenv lazy-load * fix: profile eager load * fix: caching * fix: spelling * fix: compinit/spelling * fix: feedback * fix: comments * Remove TRAPINT/flash customization, use stock Ctrl+C behavior * feat: re-introduce flash * fix: error display * feat: clear suggestions on ctrl+c * feat: grey prompt indicator * feat: git * feat: git spacing * feat: async git * feat: git perf * fix: var names * fix: exits
This commit is contained in:
@@ -1,73 +1,29 @@
|
||||
# xdg data & config
|
||||
# -----------------------------------------------------------------
|
||||
export XDG_DATA_HOME=${XDG_DATA_HOME:-"$HOME/.local/share"}
|
||||
mkdir -p "$XDG_DATA_HOME"
|
||||
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"}
|
||||
mkdir -p "$XDG_CONFIG_HOME"
|
||||
# Environment
|
||||
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
export WORKSPACE="${WORKSPACE:-$HOME/Workspace}"
|
||||
export DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
|
||||
|
||||
# local user binaries
|
||||
# -----------------------------------------------------------------
|
||||
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
# Tool roots
|
||||
export NVM_DIR="${NVM_DIR:-$HOME/.config/nvm}"
|
||||
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}"
|
||||
export POETRY_ROOT="${POETRY_ROOT:-$HOME/.poetry}"
|
||||
export HOMEBREW_NO_ANALYTICS=1
|
||||
|
||||
# PATH setup with caching
|
||||
_dots_path_cache="${XDG_CACHE_HOME:-$HOME/.cache}/dots/path"
|
||||
if [[ -f "$_dots_path_cache" && "$_dots_path_cache" -nt ~/.profile ]]; then
|
||||
export PATH="$(cat "$_dots_path_cache")"
|
||||
else
|
||||
[[ ":$PATH:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH"
|
||||
[[ ":$PATH:" != *":$PYENV_ROOT/shims:"* ]] && export PATH="$PYENV_ROOT/shims:$PATH"
|
||||
[[ ":$PATH:" != *":$PYENV_ROOT/bin:"* ]] && export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
[[ ":$PATH:" != *":$POETRY_ROOT/bin:"* ]] && export PATH="$POETRY_ROOT/bin:$PATH"
|
||||
[[ -x "/opt/homebrew/bin/brew" && ":$PATH:" != *":/opt/homebrew/bin:"* ]] && export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
|
||||
[ -f "$NVM_DIR/alias/lts/jod" ] && export PATH="$NVM_DIR/versions/node/$(cat "$NVM_DIR/alias/lts/jod")/bin:$PATH"
|
||||
|
||||
# Cache the result
|
||||
mkdir -p "$(dirname "$_dots_path_cache")"
|
||||
echo "$PATH" > "$_dots_path_cache"
|
||||
fi
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
|
||||
# workspace
|
||||
# -----------------------------------------------------------------
|
||||
export WORKSPACE=${WORKSPACE:-"$HOME/Workspace"}
|
||||
mkdir -p "$WORKSPACE"
|
||||
|
||||
# dotfiles
|
||||
# -----------------------------------------------------------------
|
||||
export DOTFILES=${DOTFILES:-"$HOME/.dotfiles"}
|
||||
|
||||
# Initialise and load Node
|
||||
# -----------------------------------------------------------------
|
||||
export NVM_DIR=${NVM_DIR:-"$HOME/.nvm"}
|
||||
mkdir -p "$NVM_DIR"
|
||||
|
||||
_dots_load_nvm() {
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||
}
|
||||
_dots_load_nvm
|
||||
|
||||
node_alias="$NVM_DIR/alias/lts/jod"
|
||||
if [ -f "$node_alias" ]; then
|
||||
VERSION=$(cat "$node_alias")
|
||||
node_bin_path="$NVM_DIR/versions/node/$VERSION/bin"
|
||||
if [[ ":$PATH:" != *":$node_bin_path:"* ]]; then
|
||||
export PATH="$node_bin_path:$PATH"
|
||||
fi
|
||||
fi
|
||||
unset node_alias VERSION node_bin_path
|
||||
|
||||
# Initialise and load Python
|
||||
# -----------------------------------------------------------------
|
||||
export PYENV_ROOT=${PYENV_ROOT:-"$HOME/.pyenv"}
|
||||
if [[ ":$PATH:" != *":$PYENV_ROOT/bin:"* ]]; then
|
||||
export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
fi
|
||||
_dots_load_pyenv() {
|
||||
[ -x $(command -v pyenv) ] && eval "$(pyenv init --path)"
|
||||
}
|
||||
_dots_load_pyenv
|
||||
|
||||
export POETRY_ROOT=${POETRY_ROOT:-"$HOME/.poetry"}
|
||||
if [[ ":$PATH:" != *":$POETRY_ROOT/bin:"* ]]; then
|
||||
export PATH="$POETRY_ROOT/bin:$PATH"
|
||||
fi
|
||||
|
||||
# aliases
|
||||
# -----------------------------------------------------------------
|
||||
if [ -f ~/.aliases ]; then
|
||||
source ~/.aliases
|
||||
fi
|
||||
|
||||
# Load homebrew
|
||||
# -----------------------------------------------------------------------------
|
||||
_dots_load_brew() {
|
||||
export HOMEBREW_NO_ANALYTICS=1
|
||||
[ -x "/opt/homebrew/bin/brew" ] && eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
}
|
||||
_dots_load_brew
|
||||
unset _dots_path_cache
|
||||
|
||||
Reference in New Issue
Block a user