diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index 8bf4565..6d71686 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -1,5 +1,7 @@ -#set-option -g default-shell /usr/bin/zsh -set -g default-command /usr/bin/zsh +# Update environment on attach +set-option -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY" + +set -g default-shell /usr/bin/zsh # Enable RGB colors if your terminal supports it diff --git a/zsh/.zshrc b/zsh/.zshrc index c349f1e..00e1437 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,127 +1,290 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH +# ============================================================================ +# ADLee's ZSH Configuration +# ============================================================================ -# Path to your Oh My Zsh installation. +# 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" -# 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 + +# Path to oh-my-zsh installation +export ZSH="$HOME/.oh-my-zsh" + +# ============================================================================ +# Theme Configuration +# ============================================================================ + ZSH_THEME="adlee" -#zstyle ':omz:alpha:lib:git' async-prompt no +# ============================================================================ +# Oh-My-Zsh Settings +# ============================================================================ -# 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" ) +# Update behavior +zstyle ':omz:update' mode reminder +zstyle ':omz:update' frequency 13 -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" +# Display red dots whilst waiting for completion +COMPLETION_WAITING_DOTS="true" -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" +# History timestamp format +HIST_STAMPS="yyyy-mm-dd" -# 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 +# ============================================================================ +# Plugins +# ============================================================================ -# Uncomment the following line to change how often to auto-update (in days). -# zstyle ':omz:update' frequency 13 +plugins=( + git + docker + docker-compose + kubectl + sudo + fzf + zsh-autosuggestions + zsh-syntax-highlighting +) -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS="true" +# Note: Install additional plugins with: +# git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +# git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting -# 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) +# ============================================================================ +# Load Oh-My-Zsh +# ============================================================================ source $ZSH/oh-my-zsh.sh +# ============================================================================ +# User Configuration +# ============================================================================ +# --- Environment Variables --- -# User configuration +export EDITOR='vim' +export VISUAL='vim' -# export MANPATH="/usr/local/man:$MANPATH" +# Language environment +export LANG=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 +# Add local bin to PATH +export PATH="$HOME/.local/bin:$PATH" -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='nvim' -# fi +# --- Aliases --- -# Compilation flags -# export ARCHFLAGS="-arch $(uname -m)" +# Navigation +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias ~='cd ~' -# 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" +# List files +if command -v eza &> /dev/null; then + alias ls='eza --icons' + alias ll='eza -lah --icons' + alias la='eza -a --icons' + alias lt='eza --tree --level=2 --icons' +else + alias ll='ls -lah' + alias la='ls -A' +fi -# GitHub token helper -gh-token-setup() { - echo "Enter your GitHub username:" - read gh_user - echo "Enter your GitHub personal access token:" - read -s gh_token - - git config --global credential.helper store - echo "https://${gh_user}:${gh_token}@github.com" > ~/.git-credentials - chmod 600 ~/.git-credentials - - echo "✓ GitHub token configured!" +# Cat with syntax highlighting +if command -v batcat &> /dev/null; then + alias cat='batcat --paging=never' + alias bat='batcat' +elif command -v bat &> /dev/null; then + alias cat='bat --paging=never' +fi + +# Git shortcuts +alias g='git' +alias gs='git status' +alias ga='git add' +alias gc='git commit' +alias gp='git push' +alias gl='git pull' +alias gd='git diff' +alias gco='git checkout' +alias gb='git branch' +alias glog='git log --oneline --graph --decorate --all' + +# Docker shortcuts +alias d='docker' +alias dc='docker-compose' +alias dps='docker ps' +alias dpa='docker ps -a' +alias di='docker images' +alias dex='docker exec -it' + +# System shortcuts +alias reload='source ~/.zshrc' +alias zshconfig='vim ~/.zshrc' +alias themeconfig='vim ~/.oh-my-zsh/themes/adlee.zsh-theme' +alias h='history' +alias c='clear' + +# Safe operations +alias rm='rm -i' +alias cp='cp -i' +alias mv='mv -i' + +# Network +alias myip='curl ifconfig.me' +alias ports='netstat -tulanp' + +# --- Functions --- + +# Create directory and cd into it +mkcd() { + mkdir -p "$1" && cd "$1" } -# Uncomment if you want any custom functions enabled. -source $HOME/.dotfiles/zsh/functions/snapper.zsh +# Extract various archive formats +extract() { + if [ -f "$1" ]; then + case "$1" in + *.tar.bz2) tar xjf "$1" ;; + *.tar.gz) tar xzf "$1" ;; + *.bz2) bunzip2 "$1" ;; + *.rar) unrar x "$1" ;; + *.gz) gunzip "$1" ;; + *.tar) tar xf "$1" ;; + *.tbz2) tar xjf "$1" ;; + *.tgz) tar xzf "$1" ;; + *.zip) unzip "$1" ;; + *.Z) uncompress "$1" ;; + *.7z) 7z x "$1" ;; + *) echo "'$1' cannot be extracted via extract()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} +# Quick find file +ff() { + find . -type f -iname "*$1*" +} + +# Quick find directory +fd() { + find . -type d -iname "*$1*" +} + +# Quick backup +backup() { + cp "$1" "$1.backup-$(date +%Y%m%d-%H%M%S)" +} + +# --- FZF Configuration --- + +if command -v fzf &> /dev/null; then + # Use fd if available for better performance + if command -v fd &> /dev/null; then + export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' + export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" + fi + + # FZF color scheme + export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border' + + # CTRL-R for history search + bindkey '^R' fzf-history-widget +fi + +# --- History Configuration --- + +HISTSIZE=10000 +SAVEHIST=10000 +HISTFILE=~/.zsh_history + +# Share history between sessions +setopt SHARE_HISTORY +setopt APPEND_HISTORY +setopt EXTENDED_HISTORY +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_FIND_NO_DUPS +setopt HIST_IGNORE_SPACE + +# --- Key Bindings --- + +# Bind Ctrl+Left/Right to move by word +bindkey "^[[1;5C" forward-word +bindkey "^[[1;5D" backward-word + +# Bind Home/End keys +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 +reload-zsh() { + source ~/.zshrc + echo "✓ zsh configuration reloaded" + zle reset-prompt +} +zle -N reload-zsh +bindkey "^[r" reload-zsh # Alt+R + +# Alt+G to show git status +git-status-widget() { + echo + git status + zle reset-prompt +} +zle -N git-status-widget +bindkey "^[g" git-status-widget # Alt+G + +# --- Application-Specific Settings --- + +# Node Version Manager (if installed) +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 +export WORKON_HOME=$HOME/.virtualenvs +export VIRTUALENVWRAPPER_PYTHON=$(which python3) +[ -f /usr/local/bin/virtualenvwrapper.sh ] && source /usr/local/bin/virtualenvwrapper.sh + +# Rust cargo +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" + +# --- OS-Specific Configuration --- + +case "$(uname -s)" in + Darwin*) + # macOS specific settings + export HOMEBREW_NO_ANALYTICS=1 + ;; + Linux*) + # Linux specific settings + ;; +esac + +# --- Snapper Functions --- + +# Source snapper snapshot management functions +if [[ -f "$HOME/.dotfiles/zsh/functions/snapper.zsh" ]]; then + source "$HOME/.dotfiles/zsh/functions/snapper.zsh" +fi + +# --- Local Configuration --- + +# Load local configuration if it exists (for machine-specific settings) +[ -f ~/.zshrc.local ] && source ~/.zshrc.local + +# ============================================================================ +# End of Configuration +# ============================================================================ diff --git a/zsh/temp b/zsh/temp new file mode 100755 index 0000000..1fca4dd --- /dev/null +++ b/zsh/temp @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting + + diff --git a/zsh/themes/adlee.zsh-theme b/zsh/themes/adlee.zsh-theme index 2edbc98..6d7e0fd 100644 --- a/zsh/themes/adlee.zsh-theme +++ b/zsh/themes/adlee.zsh-theme @@ -9,49 +9,56 @@ # ============================================================================ setopt PROMPT_SUBST -# Ensure proper line handling in tmux setopt PROMPT_CR setopt PROMPT_SP -setopt TYPESET_SILENT +setopt TYPESET_SILENT export PROMPT_EOL_MARK='' -# Prevent multiple initialization on reload -if [[ -z "$_ADLEE_THEME_LOADED" || "$TERM" = 'tmux-256color' ]] ; then - export _ADLEE_THEME_LOADED=1 - - export KEYTIMEOUT=1 - - # Color definitions - typeset -g COLOR_GREY='%{$FG[239]%}' - typeset -g COLOR_YELLOW='%{$FG[179]%}' - typeset -g COLOR_BLUE='%{$FG[069]%}' - typeset -g COLOR_GREEN='%{$FG[118]%}' - typeset -g COLOR_RED='%{$FG[196]%}' - typeset -g COLOR_ORANGE='%{$FG[220]%}' - typeset -g COLOR_LIGHT_ORANGE='%{$FG[228]%}' - typeset -g COLOR_LIGHT_GREEN='%{$FG[002]%}' - typeset -g COLOR_BRIGHT_GREEN='%{$FG[010]%}' - typeset -g COLOR_RESET='%{$reset_color%}' - typeset -g COLOR_BOLD='%{$FX[bold]%}' - - # Prompt characters - typeset -g PROMPT_CHAR_USER="${COLOR_GREY}└${COLOR_BOLD}${COLOR_BLUE}%#${COLOR_RESET} " - typeset -g PROMPT_CHAR_ROOT="${COLOR_GREY}└${COLOR_BOLD}${COLOR_RED}%#${COLOR_RESET} " - - # Path truncation threshold - typeset -g PATH_TRUNCATE_LENGTH=32 - - # Timer threshold (seconds) - typeset -g TIMER_THRESHOLD=10 -fi +# Force color loading (critical for tmux) +autoload -U colors && colors + +export KEYTIMEOUT=1 + +# Color definitions - always set these +typeset -g COLOR_GREY='%{$FG[239]%}' +typeset -g COLOR_YELLOW='%{$FG[179]%}' +typeset -g COLOR_BLUE='%{$FG[069]%}' +typeset -g COLOR_GREEN='%{$FG[118]%}' +typeset -g COLOR_RED='%{$FG[196]%}' +typeset -g COLOR_ORANGE='%{$FG[220]%}' +typeset -g COLOR_LIGHT_ORANGE='%{$FG[228]%}' +typeset -g COLOR_LIGHT_GREEN='%{$FG[002]%}' +typeset -g COLOR_BRIGHT_GREEN='%{$FG[010]%}' +typeset -g COLOR_RESET='%{$reset_color%}' +typeset -g COLOR_BOLD='%{$FX[bold]%}' + +# Prompt characters +typeset -g PROMPT_CHAR_USER="${COLOR_GREY}└${COLOR_BOLD}${COLOR_BLUE}%#${COLOR_RESET} " +typeset -g PROMPT_CHAR_ROOT="${COLOR_GREY}└${COLOR_BOLD}${COLOR_RED}%#${COLOR_RESET} " + +# Path truncation threshold +typeset -g PATH_TRUNCATE_LENGTH=32 + +# Timer threshold (seconds) +typeset -g TIMER_THRESHOLD=10 # ============================================================================ # GIT PROMPT CONFIGURATION # ============================================================================ -ZSH_THEME_GIT_PROMPT_PREFIX="]─[%{$fg_bold[green]%}" +# 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_SUFFIX="%{$reset_color$FG[239]%}" +#ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}" +#ZSH_THEME_GIT_PROMPT_CLEAN="" + +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_DIRTY=" %{$fg[red]%}*" ZSH_THEME_GIT_PROMPT_CLEAN="" # ============================================================================ @@ -130,25 +137,21 @@ _adlee_format_elapsed_time() { # 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)" -#} -# + +# 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() { - PROMPT="${COLOR_GREY}┌[${COLOR_GREEN}%n@%m${COLOR_RESET}${COLOR_GREY}]─[${COLOR_YELLOW}%~${COLOR_RESET}${COLOR_GREY}\$(git_prompt_info)${COLOR_GREY}] -${COLOR_GREY}└${COLOR_BOLD}${COLOR_BLUE}%#${COLOR_RESET} " + # Use direct color codes instead of variables in PROMPT + 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[069]%}%#%{$reset_color%} ' } + + # ============================================================================ # ZSH HOOKS # ============================================================================ @@ -198,6 +201,11 @@ histsearch() { # Load required functions 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 precmd adlee_precmd