# ____ __ # / __ )____ ______/ /_ # / __ / __ `/ ___/ __ \ # / /_/ / /_/ (__ ) / / / # /_____/\__,_/____/_/ /_/ # # Corey Smith # Bash Configuration # corey@littleplummercreek.studio # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize export EDITOR=nvim # ------------------------------------------------------------------------------ # 1Password # ------------------------------------------------------------------------------ # # Use the 1Password agent to manage ssh keys # export SSH_AUTH_SOCK=~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock # ------------------------------------------------------------------------------ # XDG Base Directory Specification # ------------------------------------------------------------------------------ # # Define standard locations for configuration and data files # # Define XDG directories export XDG_CONFIG_HOME="$HOME/.config" export XDG_CACHE_HOME="$HOME/.cache" export XDG_DATA_HOME="$HOME/.local/share" export XDG_STATE_HOME="$HOME/.local/state" # Ensure directories exist (only create if they don't exist) [ ! -d "$XDG_CONFIG_HOME" ] && mkdir -p "$XDG_CONFIG_HOME" [ ! -d "$XDG_DATA_HOME" ] && mkdir -p "$XDG_DATA_HOME" [ ! -d "$XDG_CACHE_HOME" ] && mkdir -p "$XDG_CACHE_HOME" [ ! -d "$XDG_STATE_HOME" ] && mkdir -p "$XDG_STATE_HOME" [ ! -d "$HOME/.local/bin" ] && mkdir -p "$HOME/.local/bin" # Rustup XDG compliance export RUSTUP_HOME="$XDG_DATA_HOME"/rustup # Node.js and npm XDG compliance [ ! -d "$XDG_CONFIG_HOME/npm/config" ] && mkdir -p "$XDG_CONFIG_HOME/npm/config" [ ! -d "$XDG_CACHE_HOME/npm" ] && mkdir -p "$XDG_CACHE_HOME/npm" export NODE_REPL_HISTORY="$XDG_STATE_HOME/node_repl_history" export NPM_CONFIG_CACHE="$XDG_CACHE_HOME/npm" export NPM_CONFIG_INIT_MODULE="$XDG_CONFIG_HOME/npm/config/npm-init.js" export NVM_DIR="/Users/corey/Library/Application Support/Herd/config/nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm # Less don't make a history file export LESSHISTFILE="/dev/null" # ------------------------------------------------------------------------------ # PATH Configuration # ------------------------------------------------------------------------------ # # Set up the PATH environment variable with all necessary directories # # Start with a minimal system PATH PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" # Add user's personal bin directory (highest priority) if [ -d "$HOME/bin" ]; then PATH="$HOME/bin:$PATH" fi # Add user's local bin directory PATH="$HOME/.local/bin:$PATH" # Add Homebrew directories if [ -d "/opt/homebrew/bin" ]; then PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" fi # Export the final PATH export PATH # ------------------------------------------------------------------------------ # Export terminal type # ------------------------------------------------------------------------------ # # Set terminal to 256color mode for use with custom color schemes # export TERM="xterm-256color" # ------------------------------------------------------------------------------ # Prompt # ------------------------------------------------------------------------------ # # Simple prompt matching Ubuntu's default style with colors # # A more detailed git prompt parser # Part 1: Function to get the raw git status text # (This function is the same as before) parse_git_prompt() { local git_status git_status=$(git status --porcelain -b 2>/dev/null) [[ -z "$git_status" ]] && return local branch_line branch_line=$(echo "$git_status" | head -n 1) local branch_icon=" " local branch_name branch_name=$(echo "$branch_line" | sed -e 's/^## //' -e 's/\.\..*$//') local ahead=0 behind=0 if [[ "$branch_line" =~ ahead\ ([0-9]+) ]]; then ahead=${BASH_REMATCH[1]} fi if [[ "$branch_line" =~ behind\ ([0-9]+) ]]; then behind=${BASH_REMATCH[1]} fi local file_status file_status=$(echo "$git_status" | tail -n +2) local added=0 changed=0 deleted=0 if [[ -n "$file_status" ]]; then added=$(echo "$file_status" | grep -c "^??") deleted=$(echo "$file_status" | grep -c " D ") changed=$(echo "$file_status" | grep -c "M") fi local prompt_parts=() prompt_parts+=("$branch_icon $branch_name") ((behind > 0)) && prompt_parts+=("$behind behind") ((ahead > 0)) && prompt_parts+=("$ahead ahead") ((changed > 0)) && prompt_parts+=("$changed changed") ((added > 0)) && prompt_parts+=("$added added") ((deleted > 0)) && prompt_parts+=("$deleted deleted") local prompt_string prompt_string=$(IFS=' '; echo "${prompt_parts[*]}") echo "$prompt_string" } # Part 2: A new function that builds the git line only if needed build_prompt() { local git_info git_info=$(parse_git_prompt) if [[ -n "$git_info" ]]; then # If we are in a git repo, build the full line with a newline, # color, the git info, and a color reset. # The \[ and \] are crucial to tell Bash not to count the color # codes as characters, which prevents line-wrapping bugs. GIT_PROMPT_LINE="\n\[\033[90m\]${git_info}\[\033[00m\]" else # Otherwise, the variable is empty. GIT_PROMPT_LINE="" fi } # Part 3: Set PROMPT_COMMAND and the final PS1 # # PROMPT_COMMAND runs the `build_prompt` function before displaying the prompt. PROMPT_COMMAND=build_prompt # # The PS1 now includes the ${GIT_PROMPT_LINE} variable. This will either # be the formatted git string or an empty string. PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\${GIT_PROMPT_LINE}\n" export PYTHON_HISTORY="$HOME/.local/state/python_history" # ------------------------------------------------------------------------------ # Shell History # ------------------------------------------------------------------------------ # # # Control duplicates and space-prefixed commands HISTCONTROL=ignoreboth:erasedups # History file size HISTFILESIZE=100000 HISTSIZE=$HISTFILESIZE # Add timestamps to history HISTTIMEFORMAT="%F %T " # Sync history across terminal sessions without clearing PROMPT_COMMAND="history -a && history -n" # History behavior settings shopt -s cmdhist shopt -s histappend shopt -s histreedit shopt -s histverify shopt -s lithist # ------------------------------------------------------------------------------ # Tmux Configuration # ------------------------------------------------------------------------------ # # Settings for Tmux integration # if [[ ! $(tmux list-sessions) ]]; then tmux new -s Tmux; fi # ------------------------------------------------------------------------------ # fzf # ------------------------------------------------------------------------------ # # https://github.com/junegunn/fzf # # fzf is a general-purpose command-line fuzzy finder that can be used with # any list: files, command history, processes, hostnames, bookmarks, etc. # # Key bindings enabled by fzf --bash: # Ctrl-T: Paste the selected files and directories onto the command-line # Ctrl-R: Paste the selected command from history onto the command-line # Alt-C: cd into the selected directory # # The external .fzfrc file contains detailed color schemes, preview settings, # and custom bindings for a clean, minimal interface with vim integration. # # eval "$(fzf --bash)" export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow" export FZF_DEFAULT_OPTS=" --style='full' --prompt='🔎 Find: ' --border='none' --reverse --color='light' --color='hl:#777777:regular:underline' --color='current-fg:#F7F6F3' --color='current-bg:#3B82F6' --color='current-hl:#F7F6F3:regular:underline' --color='gutter:-1' --color='pointer:-1' --color='list-border:#000000' --color='preview-border:#000000' --color='input-border:#000000' --color='header-border:#000000' --list-border='double' --input-border='double' --preview-border='double' --no-scrollbar --pointer='' --multi " export FZF_CTRL_R_OPTS=" --prompt='⏰ Command History: ' --reverse --height 100% " export FZF_CTRL_T_OPTS=" --prompt='📄 Select Files: ' --reverse --height 100% " export FZF_ALT_C_OPTS=" --prompt='📁 Navigate To: ' " # export FZF_DEFAULT_OPTS_FILE=~/.fzfrc # ------------------------------------------------------------------------------ # Mise # ------------------------------------------------------------------------------ # # # eval "$(mise activate bash)" # ------------------------------------------------------------------------------ # Alias # ------------------------------------------------------------------------------ # # # alias ls='ls -CG' # ------------------------------------------------------------------------------ # Zoxide # ------------------------------------------------------------------------------ # # Setup zsh completions and zoxide cd jumping # eval "$(zoxide init bash)"