Cleaned up some duplicate logic, shaved some timee of loading prompt.
This commit is contained in:
117
zsh/.zshrc
117
zsh/.zshrc
@@ -2,16 +2,6 @@
|
|||||||
# ADLee's ZSH Configuration
|
# ADLee's ZSH Configuration
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Force proper initialization in tmux
|
|
||||||
if [[ -n "$TMUX" ]]; then
|
|
||||||
# Ensure oh-my-zsh paths are set
|
|
||||||
export ZSH="$HOME/.oh-my-zsh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Path to oh-my-zsh installation
|
|
||||||
export ZSH="$HOME/.oh-my-zsh"
|
|
||||||
|
|
||||||
|
|
||||||
# Path to oh-my-zsh installation
|
# Path to oh-my-zsh installation
|
||||||
export ZSH="$HOME/.oh-my-zsh"
|
export ZSH="$HOME/.oh-my-zsh"
|
||||||
|
|
||||||
@@ -68,12 +58,8 @@ source $ZSH/oh-my-zsh.sh
|
|||||||
|
|
||||||
export EDITOR='vim'
|
export EDITOR='vim'
|
||||||
export VISUAL='vim'
|
export VISUAL='vim'
|
||||||
|
|
||||||
# Language environment
|
|
||||||
export LANG=en_US.UTF-8
|
export LANG=en_US.UTF-8
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
# Add local bin to PATH
|
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
|
||||||
# --- Aliases ---
|
# --- Aliases ---
|
||||||
@@ -140,7 +126,7 @@ alias myip='curl ifconfig.me'
|
|||||||
alias ports='netstat -tulanp'
|
alias ports='netstat -tulanp'
|
||||||
|
|
||||||
# --- Functions ---
|
# --- Functions ---
|
||||||
#
|
|
||||||
# Juuuust puuush it.
|
# Juuuust puuush it.
|
||||||
push-it() {
|
push-it() {
|
||||||
git add .
|
git add .
|
||||||
@@ -155,7 +141,7 @@ mkcd() {
|
|||||||
|
|
||||||
# Extract various archive formats
|
# Extract various archive formats
|
||||||
extract() {
|
extract() {
|
||||||
if [ -f "$1" ]; then
|
if [[ -f "$1" ]]; then
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*.tar.bz2) tar xjf "$1" ;;
|
*.tar.bz2) tar xjf "$1" ;;
|
||||||
*.tar.gz) tar xzf "$1" ;;
|
*.tar.gz) tar xzf "$1" ;;
|
||||||
@@ -180,8 +166,8 @@ ff() {
|
|||||||
find . -type f -iname "*$1*"
|
find . -type f -iname "*$1*"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Quick find directory
|
# Quick find directory (renamed to avoid conflict with fd tool)
|
||||||
fd() {
|
fdir() {
|
||||||
find . -type d -iname "*$1*"
|
find . -type d -iname "*$1*"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,16 +179,11 @@ backup() {
|
|||||||
# --- FZF Configuration ---
|
# --- FZF Configuration ---
|
||||||
|
|
||||||
if command -v fzf &> /dev/null; then
|
if command -v fzf &> /dev/null; then
|
||||||
# Use fd if available for better performance
|
|
||||||
if command -v fd &> /dev/null; then
|
if command -v fd &> /dev/null; then
|
||||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
|
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
|
||||||
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# FZF color scheme
|
|
||||||
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
|
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
|
||||||
|
|
||||||
# CTRL-R for history search
|
|
||||||
bindkey '^R' fzf-history-widget
|
bindkey '^R' fzf-history-widget
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -212,7 +193,6 @@ HISTSIZE=10000
|
|||||||
SAVEHIST=10000
|
SAVEHIST=10000
|
||||||
HISTFILE=~/.zsh_history
|
HISTFILE=~/.zsh_history
|
||||||
|
|
||||||
# Share history between sessions
|
|
||||||
setopt SHARE_HISTORY
|
setopt SHARE_HISTORY
|
||||||
setopt APPEND_HISTORY
|
setopt APPEND_HISTORY
|
||||||
setopt EXTENDED_HISTORY
|
setopt EXTENDED_HISTORY
|
||||||
@@ -222,18 +202,13 @@ setopt HIST_IGNORE_SPACE
|
|||||||
|
|
||||||
# --- Key Bindings ---
|
# --- Key Bindings ---
|
||||||
|
|
||||||
# Bind Ctrl+Left/Right to move by word
|
bindkey "^[[1;5C" forward-word # Ctrl+Right
|
||||||
bindkey "^[[1;5C" forward-word
|
bindkey "^[[1;5D" backward-word # Ctrl+Left
|
||||||
bindkey "^[[1;5D" backward-word
|
bindkey "^[[H" beginning-of-line # Home
|
||||||
|
bindkey "^[[F" end-of-line # End
|
||||||
|
bindkey "^[[3~" delete-char # Delete
|
||||||
|
|
||||||
# Bind Home/End keys
|
# --- Custom Widgets ---
|
||||||
bindkey "^[[H" beginning-of-line
|
|
||||||
bindkey "^[[F" end-of-line
|
|
||||||
|
|
||||||
# Bind Delete key
|
|
||||||
bindkey "^[[3~" delete-char
|
|
||||||
|
|
||||||
# --- Custom Key Bindings ---
|
|
||||||
|
|
||||||
# Alt+R to reload zsh config
|
# Alt+R to reload zsh config
|
||||||
reload-zsh() {
|
reload-zsh() {
|
||||||
@@ -242,7 +217,7 @@ reload-zsh() {
|
|||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N reload-zsh
|
zle -N reload-zsh
|
||||||
bindkey "^[r" reload-zsh # Alt+R
|
bindkey "^[r" reload-zsh
|
||||||
|
|
||||||
# Alt+G to show git status
|
# Alt+G to show git status
|
||||||
git-status-widget() {
|
git-status-widget() {
|
||||||
@@ -251,45 +226,85 @@ git-status-widget() {
|
|||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N git-status-widget
|
zle -N git-status-widget
|
||||||
bindkey "^[g" git-status-widget # Alt+G
|
bindkey "^[g" git-status-widget
|
||||||
|
|
||||||
# --- Application-Specific Settings ---
|
# ============================================================================
|
||||||
|
# Lazy-loaded Tools (for faster shell startup)
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
# Node Version Manager (if installed)
|
# --- NVM (lazy load) ---
|
||||||
|
# Only loads when you first use node, npm, nvm, or npx
|
||||||
export NVM_DIR="$HOME/.nvm"
|
export NVM_DIR="$HOME/.nvm"
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
||||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
|
||||||
|
|
||||||
# Python virtual environment
|
_load_nvm() {
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create lazy-load wrappers
|
||||||
|
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
||||||
|
nvm() {
|
||||||
|
unfunction nvm node npm npx 2>/dev/null
|
||||||
|
_load_nvm
|
||||||
|
nvm "$@"
|
||||||
|
}
|
||||||
|
node() {
|
||||||
|
unfunction nvm node npm npx 2>/dev/null
|
||||||
|
_load_nvm
|
||||||
|
node "$@"
|
||||||
|
}
|
||||||
|
npm() {
|
||||||
|
unfunction nvm node npm npx 2>/dev/null
|
||||||
|
_load_nvm
|
||||||
|
npm "$@"
|
||||||
|
}
|
||||||
|
npx() {
|
||||||
|
unfunction nvm node npm npx 2>/dev/null
|
||||||
|
_load_nvm
|
||||||
|
npx "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Python virtualenvwrapper (lazy load) ---
|
||||||
export WORKON_HOME=$HOME/.virtualenvs
|
export WORKON_HOME=$HOME/.virtualenvs
|
||||||
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
|
|
||||||
[ -f /usr/local/bin/virtualenvwrapper.sh ] && source /usr/local/bin/virtualenvwrapper.sh
|
|
||||||
|
|
||||||
# Rust cargo
|
_load_virtualenvwrapper() {
|
||||||
|
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
|
||||||
|
[ -f /usr/local/bin/virtualenvwrapper.sh ] && source /usr/local/bin/virtualenvwrapper.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
|
||||||
|
workon() {
|
||||||
|
unfunction workon mkvirtualenv rmvirtualenv 2>/dev/null
|
||||||
|
_load_virtualenvwrapper
|
||||||
|
workon "$@"
|
||||||
|
}
|
||||||
|
mkvirtualenv() {
|
||||||
|
unfunction workon mkvirtualenv rmvirtualenv 2>/dev/null
|
||||||
|
_load_virtualenvwrapper
|
||||||
|
mkvirtualenv "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Rust cargo (only if exists) ---
|
||||||
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
|
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
|
||||||
|
|
||||||
# --- OS-Specific Configuration ---
|
# --- OS-Specific Configuration ---
|
||||||
|
|
||||||
case "$(uname -s)" in
|
case "$(uname -s)" in
|
||||||
Darwin*)
|
Darwin*)
|
||||||
# macOS specific settings
|
|
||||||
export HOMEBREW_NO_ANALYTICS=1
|
export HOMEBREW_NO_ANALYTICS=1
|
||||||
;;
|
;;
|
||||||
Linux*)
|
|
||||||
# Linux specific settings
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# --- Snapper Functions ---
|
# --- Snapper Functions ---
|
||||||
|
|
||||||
# Source snapper snapshot management functions
|
|
||||||
if [[ -f "$HOME/.dotfiles/zsh/functions/snapper.zsh" ]]; then
|
if [[ -f "$HOME/.dotfiles/zsh/functions/snapper.zsh" ]]; then
|
||||||
source "$HOME/.dotfiles/zsh/functions/snapper.zsh"
|
source "$HOME/.dotfiles/zsh/functions/snapper.zsh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Local Configuration ---
|
# --- Local Configuration ---
|
||||||
|
|
||||||
# Load local configuration if it exists (for machine-specific settings)
|
|
||||||
[ -f ~/.zshrc.local ] && source ~/.zshrc.local
|
[ -f ~/.zshrc.local ] && source ~/.zshrc.local
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
# ============================================================================
|
||||||
# % ~/.oh-my-zsh/themes/adlee.zsh-theme
|
# ADLee's zsh Theme for oh-my-zsh
|
||||||
# === ADLee's zsh (oh-my-zsh) Theme ===
|
# ============================================================================
|
||||||
# =====================================
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# CONFIGURATION & CONSTANTS
|
# OPTIONS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
setopt PROMPT_SUBST
|
setopt PROMPT_SUBST
|
||||||
@@ -13,13 +12,16 @@ setopt PROMPT_CR
|
|||||||
setopt PROMPT_SP
|
setopt PROMPT_SP
|
||||||
setopt TYPESET_SILENT
|
setopt TYPESET_SILENT
|
||||||
export PROMPT_EOL_MARK=''
|
export PROMPT_EOL_MARK=''
|
||||||
|
export KEYTIMEOUT=1
|
||||||
|
|
||||||
# Force color loading (critical for tmux)
|
# Force color loading (critical for tmux)
|
||||||
autoload -U colors && colors
|
autoload -U colors && colors
|
||||||
|
|
||||||
export KEYTIMEOUT=1
|
# ============================================================================
|
||||||
|
# CONFIGURATION
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
# Color definitions - always set these
|
# Colors
|
||||||
typeset -g COLOR_GREY='%{$FG[239]%}'
|
typeset -g COLOR_GREY='%{$FG[239]%}'
|
||||||
typeset -g COLOR_YELLOW='%{$FG[179]%}'
|
typeset -g COLOR_YELLOW='%{$FG[179]%}'
|
||||||
typeset -g COLOR_BLUE='%{$FG[069]%}'
|
typeset -g COLOR_BLUE='%{$FG[069]%}'
|
||||||
@@ -32,105 +34,54 @@ typeset -g COLOR_BRIGHT_GREEN='%{$FG[010]%}'
|
|||||||
typeset -g COLOR_RESET='%{$reset_color%}'
|
typeset -g COLOR_RESET='%{$reset_color%}'
|
||||||
typeset -g COLOR_BOLD='%{$FX[bold]%}'
|
typeset -g COLOR_BOLD='%{$FX[bold]%}'
|
||||||
|
|
||||||
# Path truncation threshold
|
# Thresholds
|
||||||
typeset -g PATH_TRUNCATE_LENGTH=32
|
typeset -g PATH_TRUNCATE_LENGTH=32
|
||||||
|
|
||||||
# Timer threshold (seconds)
|
|
||||||
typeset -g TIMER_THRESHOLD=10
|
typeset -g TIMER_THRESHOLD=10
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# GIT PROMPT CONFIGURATION
|
# GIT PROMPT
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Force load git library for git_prompt_info
|
|
||||||
if [[ -f "$ZSH/lib/git.zsh" ]]; then
|
|
||||||
source "$ZSH/lib/git.zsh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[green]%}⎇ "
|
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[green]%}⎇ "
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color$FG[239]%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color$FG[239]%}"
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*"
|
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*"
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# HELPER FUNCTIONS
|
# COMMAND TIMER
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Get shortened path (last two directories if path is too long)
|
|
||||||
_adlee_get_short_path() {
|
|
||||||
local full_path="$(pwd | sed -e 's/\/Users\/alee/~/g')"
|
|
||||||
local path_len=$(echo -n "$full_path" | wc -m | tr -d ' ')
|
|
||||||
|
|
||||||
if [ "$path_len" -gt "$PATH_TRUNCATE_LENGTH" ]; then
|
|
||||||
local short_path=$(pwd | awk -F '/' '{print $(NF - 1)"/"$NF}')
|
|
||||||
echo "${COLOR_YELLOW}⋯${COLOR_RESET}${COLOR_GREY}${COLOR_YELLOW}/${short_path}${COLOR_RESET}${COLOR_GREY}"
|
|
||||||
else
|
|
||||||
echo "${COLOR_YELLOW}%~${COLOR_RESET}${COLOR_GREY}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Format user@host section
|
|
||||||
_adlee_format_user_host() {
|
|
||||||
echo "${COLOR_GREEN}%n@%m${COLOR_RESET}${COLOR_GREY}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Format current directory with git info
|
|
||||||
_adlee_format_directory() {
|
|
||||||
local short_path="$(_adlee_get_short_path)"
|
|
||||||
# Remove the single quotes so it gets evaluated in the prompt
|
|
||||||
echo "${short_path}\$(git_prompt_info)${COLOR_GREY}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# COMMAND TIMER FUNCTIONS
|
|
||||||
# ============================================================================
|
|
||||||
|
|
||||||
# Format elapsed time based on duration
|
|
||||||
_adlee_format_elapsed_time() {
|
_adlee_format_elapsed_time() {
|
||||||
local elapsed=$1
|
local elapsed=$1
|
||||||
local timestamp="%D{%Y-%m-%d %I:%M:%S}"
|
local timestamp="%D{%Y-%m-%d %I:%M:%S}"
|
||||||
|
|
||||||
if [[ $elapsed -ge 3600 ]]; then
|
if (( elapsed >= 3600 )); then
|
||||||
# Hours
|
|
||||||
local hours=$((elapsed / 3600))
|
local hours=$((elapsed / 3600))
|
||||||
local remainder=$((elapsed % 3600))
|
local remainder=$((elapsed % 3600))
|
||||||
local minutes=$((remainder / 60))
|
local minutes=$((remainder / 60))
|
||||||
local seconds=$((remainder % 60))
|
local seconds=$((remainder % 60))
|
||||||
print -P "${COLOR_RED}•••[ completed in: %b%B${COLOR_RED}${hours}h${minutes}m${seconds}s%b${COLOR_RED} at: %b%B${COLOR_RED}${timestamp}%b${COLOR_RED} ]•••%b"
|
print -P "${COLOR_RED}•••[ completed in: %b%B${COLOR_RED}${hours}h${minutes}m${seconds}s%b${COLOR_RED} at: %b%B${COLOR_RED}${timestamp}%b${COLOR_RED} ]•••%b"
|
||||||
elif [[ $elapsed -ge 60 ]]; then
|
elif (( elapsed >= 60 )); then
|
||||||
# Minutes
|
|
||||||
local minutes=$((elapsed / 60))
|
local minutes=$((elapsed / 60))
|
||||||
local seconds=$((elapsed % 60))
|
local seconds=$((elapsed % 60))
|
||||||
print -P "${COLOR_ORANGE}••[ completed in: %b%B${COLOR_LIGHT_ORANGE}${minutes}m${seconds}s%b${COLOR_ORANGE} at: %b%B${COLOR_LIGHT_ORANGE}${timestamp}%b${COLOR_ORANGE} ]••%b"
|
print -P "${COLOR_ORANGE}••[ completed in: %b%B${COLOR_LIGHT_ORANGE}${minutes}m${seconds}s%b${COLOR_ORANGE} at: %b%B${COLOR_LIGHT_ORANGE}${timestamp}%b${COLOR_ORANGE} ]••%b"
|
||||||
else
|
else
|
||||||
# Seconds only
|
|
||||||
print -P "${COLOR_LIGHT_GREEN}•[ completed in: %b%B${COLOR_BRIGHT_GREEN}${elapsed}s%b${COLOR_BRIGHT_GREEN} at: %b%B${COLOR_LIGHT_GREEN}${timestamp}%b${COLOR_LIGHT_GREEN} ]•%b"
|
print -P "${COLOR_LIGHT_GREEN}•[ completed in: %b%B${COLOR_BRIGHT_GREEN}${elapsed}s%b${COLOR_BRIGHT_GREEN} at: %b%B${COLOR_LIGHT_GREEN}${timestamp}%b${COLOR_LIGHT_GREEN} ]•%b"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# PROMPT BUILDING
|
# PROMPT
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
|
||||||
# Ensure git prompt function is available
|
|
||||||
if ! (( $+functions[git_prompt_info] )); then
|
|
||||||
# Git lib not loaded yet, source it manually
|
|
||||||
source "$ZSH/lib/git.zsh" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
_adlee_build_prompt() {
|
_adlee_build_prompt() {
|
||||||
# Prompt character: blue for users, red for root
|
# %(#.TRUE.FALSE) - red for root, blue for users
|
||||||
# %(#.TRUE.FALSE) - if privileged (root), use TRUE, else FALSE
|
|
||||||
PROMPT='%{$FG[239]%}┌[%{$FG[118]%}%n@%m%{$reset_color$FG[239]%}]─[%{$FG[179]%}%~%{$reset_color$FG[239]%}$(git_prompt_info)%{$FG[239]%}]
|
PROMPT='%{$FG[239]%}┌[%{$FG[118]%}%n@%m%{$reset_color$FG[239]%}]─[%{$FG[179]%}%~%{$reset_color$FG[239]%}$(git_prompt_info)%{$FG[239]%}]
|
||||||
%{$FG[239]%}└%{$FX[bold]%}%(#.%{$FG[196]%}.%{$FG[069]%})%#%{$reset_color%} '
|
%{$FG[239]%}└%{$FX[bold]%}%(#.%{$FG[196]%}.%{$FG[069]%})%#%{$reset_color%} '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# ZSH HOOKS
|
# HOOKS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
adlee_preexec() {
|
adlee_preexec() {
|
||||||
@@ -139,34 +90,24 @@ adlee_preexec() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adlee_precmd() {
|
adlee_precmd() {
|
||||||
# Handle command timer
|
|
||||||
if [[ -n $cmd_start_time ]]; then
|
if [[ -n $cmd_start_time ]]; then
|
||||||
local elapsed=$((SECONDS - cmd_start_time))
|
local elapsed=$((SECONDS - cmd_start_time))
|
||||||
if [[ $elapsed -gt $TIMER_THRESHOLD ]]; then
|
(( elapsed > TIMER_THRESHOLD )) && _adlee_format_elapsed_time $elapsed
|
||||||
_adlee_format_elapsed_time $elapsed
|
|
||||||
fi
|
|
||||||
unset cmd_start_time
|
unset cmd_start_time
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure ZLE highlighting
|
|
||||||
zle_highlight=( default:fg=white )
|
zle_highlight=( default:fg=white )
|
||||||
|
|
||||||
# Rebuild prompt
|
|
||||||
_adlee_build_prompt
|
_adlee_build_prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
TRAPALRM() {
|
TRAPALRM() {
|
||||||
_adlee_build_prompt
|
_adlee_build_prompt
|
||||||
if [[ "$WIDGET" != "expand-or-complete" ]]; then
|
[[ "$WIDGET" != "expand-or-complete" ]] && zle reset-prompt
|
||||||
zle reset-prompt
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# UTILITY FUNCTIONS
|
# UTILITIES
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Search command history
|
|
||||||
histsearch() {
|
histsearch() {
|
||||||
fc -lim "$@" 1
|
fc -lim "$@" 1
|
||||||
}
|
}
|
||||||
@@ -175,15 +116,7 @@ histsearch() {
|
|||||||
# INITIALIZATION
|
# INITIALIZATION
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Load required functions
|
|
||||||
autoload -Uz add-zsh-hook
|
autoload -Uz add-zsh-hook
|
||||||
|
|
||||||
# Force initial prompt build for tmux
|
|
||||||
if [[ -n "$TMUX" ]]; then
|
|
||||||
_adlee_build_prompt
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Register hooks
|
|
||||||
add-zsh-hook preexec adlee_preexec
|
add-zsh-hook preexec adlee_preexec
|
||||||
add-zsh-hook precmd adlee_precmd
|
add-zsh-hook precmd adlee_precmd
|
||||||
|
|
||||||
@@ -191,44 +124,28 @@ add-zsh-hook precmd adlee_precmd
|
|||||||
zle -N zle-line-init
|
zle -N zle-line-init
|
||||||
zle -N zle-keymap-select
|
zle -N zle-keymap-select
|
||||||
|
|
||||||
# Define zshrc reload function and widget
|
# Initial prompt build (critical for tmux)
|
||||||
|
_adlee_build_prompt
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# CUSTOM WIDGETS
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
reload-zshrc() {
|
reload-zshrc() {
|
||||||
echo -n "Re-sourcing \`~/.zshrc.\` ... "
|
echo -n "Re-sourcing ~/.zshrc ... "
|
||||||
source ~/.zshrc
|
source ~/.zshrc
|
||||||
echo "Completed."
|
echo "Done."
|
||||||
_adlee_build_prompt
|
_adlee_build_prompt
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N reload-zshrc # Register as a widget
|
zle -N reload-zshrc
|
||||||
bindkey "^X@s^[^R" reload-zshrc # Bind to Ctrl+Super+Alt+R
|
bindkey "^X@s^[^R" reload-zshrc # Ctrl+Super+Alt+R
|
||||||
|
|
||||||
# Function.
|
|
||||||
grab-fastfetch() {
|
grab-fastfetch() {
|
||||||
echo "fastfetch"
|
echo "fastfetch"
|
||||||
fastfetch
|
fastfetch
|
||||||
_adlee_build_prompt
|
_adlee_build_prompt
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N grab-fastfetch # Register as a widget
|
zle -N grab-fastfetch
|
||||||
bindkey "^X@s^[^F" grab-fastfetch # Bind to Ctrl+Super+Alt+F
|
bindkey "^X@s^[^F" grab-fastfetch # Ctrl+Super+Alt+F
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# DEPLOYMENT NOTES
|
|
||||||
# ============================================================================
|
|
||||||
# For system-wide deployment, use one of these approaches:
|
|
||||||
#
|
|
||||||
# OPTION 1: Symlink (Recommended)
|
|
||||||
# Master location: /usr/local/share/zsh/themes/adlee.zsh-theme
|
|
||||||
# User symlinks:
|
|
||||||
# ln -sf /usr/local/share/zsh/themes/adlee.zsh-theme ~/.oh-my-zsh/themes/adlee.zsh-theme
|
|
||||||
# sudo ln -sf /usr/local/share/zsh/themes/adlee.zsh-theme /root/.oh-my-zsh/themes/adlee.zsh-theme
|
|
||||||
#
|
|
||||||
# OPTION 2: Source from shared location
|
|
||||||
# In each user's ~/.zshrc (before oh-my-zsh initialization):
|
|
||||||
# source /usr/local/share/zsh/themes/adlee.zsh-theme
|
|
||||||
#
|
|
||||||
# OPTION 3: Custom oh-my-zsh location
|
|
||||||
# Set in ~/.zshrc:
|
|
||||||
# export ZSH_CUSTOM="/usr/local/share/oh-my-zsh-custom"
|
|
||||||
# Then place theme in: /usr/local/share/oh-my-zsh-custom/themes/adlee.zsh-theme
|
|
||||||
|
|||||||
Reference in New Issue
Block a user