Files
dotfiles/zshrc
Eric Wagoner 42fa784644 Guard Docker init scripts with existence checks
Prevents errors when Docker Desktop is not installed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 09:26:37 -05:00

166 lines
5.6 KiB
Bash

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="powerlevel10k/powerlevel10k"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Powerlevel10k Configuration
# Uncomment the following line if you want to disable marking untracked files under VCS as dirty
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Powerlevel10k Settings
POWERLEVEL9K_MODE="nerdfont-complete"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs time)
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=""
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="$ "
# History Configuration
HISTSIZE=10000 # Maximum events in internal history
SAVEHIST=10000 # Maximum events in history file
HIST_STAMPS="yyyy-mm-dd" # Add timestamps to history
setopt HIST_IGNORE_DUPS # Don't record duplicated commands
setopt HIST_FIND_NO_DUPS # Don't display duplicates when searching
setopt HIST_REDUCE_BLANKS # Remove unnecessary blanks
setopt INC_APPEND_HISTORY # Add commands to history immediately
setopt EXTENDED_HISTORY # Record command start time and duration
# Directory Navigation
setopt AUTO_CD # Change directories without typing cd
setopt AUTO_PUSHD # Push directories to the stack automatically
setopt PUSHD_IGNORE_DUPS # Don't push duplicate directories
setopt PUSHD_MINUS # Reverse meaning of +/- when navigating stack
DIRSTACKSIZE=10 # Limit directory stack size
# Command Line Editing
setopt INTERACTIVE_COMMENTS # Allow comments in interactive shell
setopt NO_BEEP # Disable beeping
setopt COMPLETE_IN_WORD # Allow completion from within a word
setopt ALWAYS_TO_END # Move cursor to end of word after completion
# Key bindings
bindkey "^[[1;5C" forward-word # Ctrl + Right
bindkey "^[[1;5D" backward-word # Ctrl + Left
bindkey '^[[H' beginning-of-line # Home
bindkey '^[[F' end-of-line # End
bindkey '^[[3~' delete-char # Delete
bindkey '^?' backward-delete-char # Backspace
bindkey '^[[A' history-beginning-search-backward # Up arrow
bindkey '^[[B' history-beginning-search-forward # Down arrow
# Example aliases
alias zshconfig="cursor ~/.zshrc"
alias ohmyzsh="cursor ~/.oh-my-zsh"
# alias python=/usr/local/bin/python3
# alias pip=/usr/local/bin/pip3
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
plugins=(
copyfile
docker
extract
fzf
git
git-auto-fetch
jira
nvm
vscode
web-search
z
zsh-autosuggestions
zsh-syntax-highlighting # Must be last in the list!
)
# Plugin Configurations
# FZF
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --preview 'bat --style=numbers --color=always --line-range :500 {}'"
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# ZSH Autosuggestions
export ZSH_AUTOSUGGEST_STRATEGY=(history completion)
export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
export ZSH_AUTOSUGGEST_USE_ASYNC=true
bindkey '^ ' autosuggest-accept # Ctrl + Space to accept suggestion
# ZSH Syntax Highlighting
export ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
export ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red')
# Auto-switch Node version when entering a directory with .nvmrc
NVM_AUTOLOAD=1
# SSH Agent configuration from Genehack
zstyle :omz:plugins:ssh-agent agent-forwarding on
# Load Oh My Zsh
source $ZSH/oh-my-zsh.sh
# Suppress NVM output for Powerlevel10k instant prompt
export NVM_QUIET=1
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
# Docker
[[ -f "$HOME/.docker/init-zsh.sh" ]] && source "$HOME/.docker/init-zsh.sh"
# iTerm2 integration
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# Utility functions
listening() {
if [ $# -eq 0 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P
elif [ $# -eq 1 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1
else
echo "Usage: listening [pattern]"
fi
}
# Aliases
alias ls='lsd'
alias weather='curl wttr.in/Athens'
alias mkdir='mkdir -p' # Create parent directories automatically
alias h='history'
alias path='echo -e ${PATH//:/\\n}' # Pretty print PATH
alias now='date +"%T"'
alias nowdate='date +"%d-%m-%Y"'
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Docker CLI completions
if [[ -d "$HOME/.docker/completions" ]]; then
fpath=($HOME/.docker/completions $fpath)
fi
autoload -Uz compinit
compinit