Initial commit: Add dotfiles and custom zsh theme
This commit is contained in:
109
zsh/.zshrc
Normal file
109
zsh/.zshrc
Normal file
@@ -0,0 +1,109 @@
|
||||
# If you come from bash you might have to change your $PATH.
|
||||
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
# Path to your Oh My Zsh installation.
|
||||
export ZSH="$HOME/.oh-my-zsh"
|
||||
|
||||
# Set name of the theme to load --- if set to "random", it will
|
||||
# load a random theme each time Oh My Zsh is loaded, in which case,
|
||||
# to know which specific one was loaded, run: echo $RANDOM_THEME
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
|
||||
ZSH_THEME="adlee"
|
||||
|
||||
zstyle ':omz:alpha:lib:git' async-prompt no
|
||||
|
||||
# Set list of themes to pick from when loading at random
|
||||
# Setting this variable when ZSH_THEME=random will cause zsh to load
|
||||
# a theme from this variable instead of looking in $ZSH/themes/
|
||||
# If set to an empty array, this variable will have no effect.
|
||||
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
|
||||
|
||||
# Uncomment the following line to use case-sensitive completion.
|
||||
# CASE_SENSITIVE="true"
|
||||
|
||||
# Uncomment the following line to use hyphen-insensitive completion.
|
||||
# Case-sensitive completion must be off. _ and - will be interchangeable.
|
||||
# HYPHEN_INSENSITIVE="true"
|
||||
|
||||
# Uncomment one of the following lines to change the auto-update behavior
|
||||
# zstyle ':omz:update' mode disabled # disable automatic updates
|
||||
# zstyle ':omz:update' mode auto # update automatically without asking
|
||||
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
|
||||
|
||||
# Uncomment the following line to change how often to auto-update (in days).
|
||||
# zstyle ':omz:update' frequency 13
|
||||
|
||||
# Uncomment the following line if pasting URLs and other text is messed up.
|
||||
# DISABLE_MAGIC_FUNCTIONS="true"
|
||||
|
||||
# Uncomment the following line to disable colors in ls.
|
||||
# DISABLE_LS_COLORS="true"
|
||||
|
||||
# Uncomment the following line to disable auto-setting terminal title.
|
||||
# DISABLE_AUTO_TITLE="true"
|
||||
|
||||
# Uncomment the following line to enable command auto-correction.
|
||||
# ENABLE_CORRECTION="true"
|
||||
|
||||
# Uncomment the following line to display red dots whilst waiting for completion.
|
||||
# You can also set it to another string to have that shown instead of the default red dots.
|
||||
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
|
||||
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
|
||||
# COMPLETION_WAITING_DOTS="true"
|
||||
|
||||
# Uncomment the following line if you want to disable marking untracked files
|
||||
# under VCS as dirty. This makes repository status check for large repositories
|
||||
# much, much faster.
|
||||
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
||||
|
||||
# Uncomment the following line if you want to change the command execution time
|
||||
# stamp shown in the history command output.
|
||||
# You can set one of the optional three formats:
|
||||
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
||||
# or set a custom format using the strftime function format specifications,
|
||||
# see 'man strftime' for details.
|
||||
# HIST_STAMPS="mm/dd/yyyy"
|
||||
|
||||
# Would you like to use another custom folder than $ZSH/custom?
|
||||
# ZSH_CUSTOM=/path/to/new-custom-folder
|
||||
|
||||
# Which plugins would you like to load?
|
||||
# Standard plugins can be found in $ZSH/plugins/
|
||||
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
# Add wisely, as too many plugins slow down shell startup.
|
||||
plugins=(git)
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
# User configuration
|
||||
|
||||
# export MANPATH="/usr/local/man:$MANPATH"
|
||||
|
||||
# You may need to manually set your language environment
|
||||
# export LANG=en_US.UTF-8
|
||||
|
||||
# Preferred editor for local and remote sessions
|
||||
# if [[ -n $SSH_CONNECTION ]]; then
|
||||
# export EDITOR='vim'
|
||||
# else
|
||||
# export EDITOR='nvim'
|
||||
# fi
|
||||
|
||||
# Compilation flags
|
||||
# export ARCHFLAGS="-arch $(uname -m)"
|
||||
|
||||
# Set personal aliases, overriding those provided by Oh My Zsh libs,
|
||||
# plugins, and themes. Aliases can be placed here, though Oh My Zsh
|
||||
# users are encouraged to define aliases within a top-level file in
|
||||
# the $ZSH_CUSTOM folder, with .zsh extension. Examples:
|
||||
# - $ZSH_CUSTOM/aliases.zsh
|
||||
# - $ZSH_CUSTOM/macos.zsh
|
||||
# For a full list of active aliases, run `alias`.
|
||||
#
|
||||
# Example aliases
|
||||
# alias zshconfig="mate ~/.zshrc"
|
||||
# alias ohmyzsh="mate ~/.oh-my-zsh"
|
||||
alias vispresso="vim ~/.config/espanso/match/base.yml"
|
||||
|
||||
|
||||
229
zsh/themes/adlee.zsh-theme
Normal file
229
zsh/themes/adlee.zsh-theme
Normal file
@@ -0,0 +1,229 @@
|
||||
#!/usr/bin/env zsh
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
# % ~/.oh-my-zsh/themes/adlee.zsh-theme
|
||||
# === ADLee's zsh (oh-my-zsh) Theme ===
|
||||
# =====================================
|
||||
|
||||
# ============================================================================
|
||||
# CONFIGURATION & CONSTANTS
|
||||
# ============================================================================
|
||||
|
||||
# Prevent multiple initialization on reload
|
||||
if [[ -z "$_ADLEE_THEME_LOADED" ]]; then
|
||||
export _ADLEE_THEME_LOADED=1
|
||||
|
||||
export KEYTIMEOUT=1
|
||||
|
||||
# Color definitions
|
||||
typeset -gr COLOR_GREY='%{$FG[239]%}'
|
||||
typeset -gr COLOR_YELLOW='%{$FG[179]%}'
|
||||
typeset -gr COLOR_BLUE='%{$FG[069]%}'
|
||||
typeset -gr COLOR_GREEN='%{$FG[118]%}'
|
||||
typeset -gr COLOR_RED='%{$FG[196]%}'
|
||||
typeset -gr COLOR_ORANGE='%{$FG[220]%}'
|
||||
typeset -gr COLOR_LIGHT_ORANGE='%{$FG[228]%}'
|
||||
typeset -gr COLOR_LIGHT_GREEN='%{$FG[002]%}'
|
||||
typeset -gr COLOR_BRIGHT_GREEN='%{$FG[010]%}'
|
||||
typeset -gr COLOR_RESET='%{$reset_color%}'
|
||||
typeset -gr COLOR_BOLD='%{$FX[bold]%}'
|
||||
|
||||
# Prompt characters
|
||||
typeset -gr PROMPT_CHAR_USER="${COLOR_GREY}└${COLOR_BOLD}${COLOR_BLUE}%#${COLOR_RESET} "
|
||||
typeset -gr PROMPT_CHAR_ROOT="${COLOR_GREY}└${COLOR_BOLD}${COLOR_RED}%#${COLOR_RESET} "
|
||||
|
||||
# Path truncation threshold
|
||||
typeset -gr PATH_TRUNCATE_LENGTH=32
|
||||
|
||||
# Timer threshold (seconds)
|
||||
typeset -gr TIMER_THRESHOLD=10
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# GIT PROMPT CONFIGURATION
|
||||
# ============================================================================
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="]─[%{$fg_bold[green]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color$FG[239]%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
|
||||
# ============================================================================
|
||||
# HELPER FUNCTIONS
|
||||
# ============================================================================
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# Get appropriate prompt character based on user
|
||||
_adlee_get_prompt_char() {
|
||||
if [[ $UID == 0 || $EUID == 0 ]]; then
|
||||
echo "$PROMPT_CHAR_ROOT"
|
||||
else
|
||||
echo "$PROMPT_CHAR_USER"
|
||||
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)"
|
||||
local git_info='$(git_prompt_info)'"${COLOR_GREY}"
|
||||
echo "${short_path}${git_info}"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# COMMAND TIMER FUNCTIONS
|
||||
# ============================================================================
|
||||
|
||||
# Format elapsed time based on duration
|
||||
_adlee_format_elapsed_time() {
|
||||
local elapsed=$1
|
||||
local timestamp="%D{%Y-%m-%d %I:%M:%S}"
|
||||
|
||||
if [[ $elapsed -ge 3600 ]]; then
|
||||
# Hours
|
||||
local hours=$((elapsed / 3600))
|
||||
local remainder=$((elapsed % 3600))
|
||||
local minutes=$((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"
|
||||
elif [[ $elapsed -ge 60 ]]; then
|
||||
# Minutes
|
||||
local minutes=$((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"
|
||||
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"
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# PROMPT BUILDING
|
||||
# ============================================================================
|
||||
|
||||
_adlee_build_prompt() {
|
||||
local user_host="$(_adlee_format_user_host)"
|
||||
local directory="$(_adlee_format_directory)"
|
||||
|
||||
# Build top line: ┌[user@host]─[directory]
|
||||
local top_line="${COLOR_GREY}┌[${user_host}]─[${directory}]"
|
||||
|
||||
print -P "${top_line}"
|
||||
|
||||
# Set bottom line prompt character
|
||||
PROMPT="$(_adlee_get_prompt_char)"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# ZSH HOOKS
|
||||
# ============================================================================
|
||||
|
||||
adlee_preexec() {
|
||||
cmd_start_time=$SECONDS
|
||||
echo -ne "\e[0m"
|
||||
}
|
||||
|
||||
adlee_precmd() {
|
||||
# Handle command timer
|
||||
if [[ -n $cmd_start_time ]]; then
|
||||
local elapsed=$((SECONDS - cmd_start_time))
|
||||
if [[ $elapsed -gt $TIMER_THRESHOLD ]]; then
|
||||
_adlee_format_elapsed_time $elapsed
|
||||
fi
|
||||
unset cmd_start_time
|
||||
fi
|
||||
|
||||
# Configure ZLE highlighting
|
||||
zle_highlight=( default:fg=white )
|
||||
|
||||
# Rebuild prompt
|
||||
_adlee_build_prompt
|
||||
}
|
||||
|
||||
TRAPALRM() {
|
||||
_adlee_build_prompt
|
||||
if [[ "$WIDGET" != "expand-or-complete" ]]; then
|
||||
zle reset-prompt
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# UTILITY FUNCTIONS
|
||||
# ============================================================================
|
||||
|
||||
# Search command history
|
||||
histsearch() {
|
||||
fc -lim "$@" 1
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# INITIALIZATION
|
||||
# ============================================================================
|
||||
|
||||
# Load required functions
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
# Register hooks
|
||||
add-zsh-hook preexec adlee_preexec
|
||||
add-zsh-hook precmd adlee_precmd
|
||||
|
||||
# Configure ZLE
|
||||
zle -N zle-line-init
|
||||
zle -N zle-keymap-select
|
||||
|
||||
# Define zshrc reload function and widget
|
||||
reload-zshrc() {
|
||||
echo -n "Re-sourcing \`~/.zshrc.\` ... "
|
||||
source ~/.zshrc
|
||||
echo "Completed."
|
||||
_adlee_build_prompt
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N reload-zshrc # Register as a widget
|
||||
bindkey "^X@s^[^R" reload-zshrc # Bind to Ctrl+Super+Alt+R
|
||||
|
||||
# Function.
|
||||
grab-fastfetch() {
|
||||
echo "fastfetch"
|
||||
fastfetch
|
||||
_adlee_build_prompt
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N grab-fastfetch # Register as a widget
|
||||
bindkey "^X@s^[^F" grab-fastfetch # Bind to 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