Skip to content

Instantly share code, notes, and snippets.

@afraser
Created October 3, 2024 16:43
Show Gist options
  • Save afraser/225545657d56a6e54f6c3f9a324909cb to your computer and use it in GitHub Desktop.
Save afraser/225545657d56a6e54f6c3f9a324909cb to your computer and use it in GitHub Desktop.
# -----------------------
# Sensible Bash - An attempt at saner Bash defaults
# Maintainer: mrzool <http://mrzool.cc>
# Update window size after every command
shopt -s checkwinsize
# Automatically trim long paths in the prompt (requires Bash 4.x)
PROMPT_DIRTRIM=2
## SMARTER TAB-COMPLETION (Readline bindings) ##
# Perform file completion in a case insensitive fashion
bind "set completion-ignore-case on"
# Treat hyphens and underscores as equivalent
bind "set completion-map-case on"
# Display matches for ambiguous patterns at first tab press
bind "set show-all-if-ambiguous on"
## SANE HISTORY DEFAULTS ##
# Append to the history file, don't overwrite it
shopt -s histappend
# Save multi-line commands as one command
shopt -s cmdhist
# Record each line as it gets issued
PROMPT_COMMAND='history -a'
# Huge history. Doesn't appear to slow things down, so why not?
HISTSIZE=500000
HISTFILESIZE=100000
# Avoid duplicate entries
HISTCONTROL="erasedups:ignoreboth"
# Don't record some commands
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history"
# Useful timestamp format
HISTTIMEFORMAT='%F %T '
## BETTER DIRECTORY NAVIGATION ##
# Prepend cd to directory names automatically
# shopt -s autocd
# Correct spelling errors during tab-completion
# shopt -s dirspell
# Correct spelling errors in arguments supplied to cd
shopt -s cdspell
PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~}\007"'
. ~/git-dirty-prompt.sh
export PATH="$HOME/bin:/usr/local/bin:$PATH"
# Git aliases
alias gs="git status -sb"
alias ga="git add -A"
alias gc="git commit -m"
alias gco="git checkout"
alias gl="git pull"
alias gd="git diff"
if [ -x /usr/local/bin/brew ]; then
export PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
# eval $(dircolors)
# alias ls='ls --color=auto --human-readable --classify'
alias find=gfind
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
fi
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment