Bash Config MacOS
Prequisites
MacOS ships with ancient bash version 3.x which is quite old. Brew install bash v5.x and modern CLI utils.
brew install bash bash-completion@2 uutils coreutils findutils diffutilsFilename: ~/.bash_profile
# Filename: ~/.bash_profile
[ -f ~/.bashrc ] && . ~/.bashrc
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
Filename: ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells0
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# Silences macos zsh warnings
export BASH_SILENCE_DEPRECATION_WARNING=1
# Add brew to path
PATH="/opt/homebrew/bin:/opt/homebrew/opt/node@22/bin:$PATH"
# Add uutils to path so GNU commands superseed MacOS commands
export PATH="/opt/homebrew/opt/uutils-findutils/libexec/uubin:$PATH"
export PATH="/opt/homebrew/opt/uutils-diffutils/libexec/uubin:$PATH"
export PATH="/opt/homebrew/opt/uutils-coreutils/libexec/uubin:$PATH"
# Add Quark env vars to bash
. /opt/quark/env.sh
# Move /usr/local/bin to the start of $PATH
export PATH="/usr/local/bin:$(echo $PATH | awk -v RS=: '$0!="/usr/local/bin"{printf "%s%s",sep,$0; sep=":"}')"
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# enable color support of ls and also add handy aliases
if [ -x /opt/homebrew/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alFh'
alias la='ls -A'
alias l='ls -CF'
# Start with a yellow prompt
PS1='\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# Draw horizontal line between commands, add time to the prompt
#PS1='\[\033[01;34m\]$(printf "%.sโ" $(seq $COLUMNS))\n[\D{%H:%M:%S}] '$PS1
#PS1='\[\033[01;34m\][\D{%H:%M:%S}] $(printf "%.sโ" $(seq $(expr $COLUMNS - 11)))\n'$PS1
# This is the current one
PS1='\[\033[01;34m\]$(printf "%.sโ" $(seq 3)) [\D{%H:%M:%S}] $(printf "%.sโ" $(seq $(expr $COLUMNS - 15)))\n'$PS1
#PS1='\[\033[01;34m\]$(printf "%.sโ" $(seq $(expr $COLUMNS - 15))) [\D{%H:%M:%S}] $(printf "%.sโ" $(seq 3))\n'$PS1
#PS1='\n\n'$PS1
# Common command sequences
sd() { cd "$@" && clear && ls -lAFh; }
# Make bash autocompletions like ZSH
bind 'set completion-ignore-case on'
#bind 'set show-all-if-ambiguous on'
# Gemini API key for Gemini CLI
export GEMINI_API_KEY='TODO'
HOMEBREW_PREFIX="/opt/homebrew"
[[ -r "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh" ]] && . "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh"
unset HOMEBREW_PREFIX