Skip to content

Instantly share code, notes, and snippets.

@davidlbatey
Created October 4, 2011 08:36
Show Gist options
  • Save davidlbatey/1261161 to your computer and use it in GitHub Desktop.
Save davidlbatey/1261161 to your computer and use it in GitHub Desktop.
bash
.bashrc
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH
[[ -s "/Users/david/.rvm/scripts/rvm" ]] && source "/Users/david/.rvm/scripts/rvm"
.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# the HISTFILESIZE environment variable sets the maximum number of lines that will ever be saved to your bash_history file
# it defaults to 1000 lines – far too few!
# We unset it, so that there is no limit on the number of lines saved to disk in ~/.bash_history
unset HISTFILESIZE
# HISTSIZE sets the maximum number of lines loaded from the history file into memory on shell startup.
# We set this to 20k to save memory – Bash doesn’t use memory very well, and a huge history file can really bloats every Bash shell process
# this limits the number of lines returned by the ‘history’ command, but you can always grep/cat the ~/.bash_history file directly
# in any case it’s unlikely you’ll exceed 20k lines ever – this is more a safety precaution.
export HISTSIZE=20000
# Setting the time format will cause every history line to be timestamped. This is useful when reviewing old commands
# So situations like “I know I had this problem in April..” can be answered more easily
# Setting this causes ~/.bash_history timestamping to be turned on; however the time format used in the history file is fixed (to seconds-since-epoch)
# The time format setting applies to the output of the ‘history’ command
# The format below is e.g. “25/06/11-01:45:10”; alter to suit your tastes. To see available format strings: man 3 strftime
export HISTTIMEFORMAT='%d/%m/%y-%H:%M:%S '
# Sets the ‘histappend’ shell option (shopt)
# This changes the default history behaviour from overwrite to append
# This prevents multiple simultaneous shells from overwriting others history
shopt -s histappend
# The command ‘history –a’ causes all new history lines to be immediately appended to the ~/.bash_history file.
# PROMPT_COMMAND is a bash variable defining a command to be executed immediately before a new prompt is displayed
# meaning it’s executed after any command is run, and before the prompt is displayed ready for the new command.
# Therefore the following causes the history to be appended to the history file after every command, and not just on shell exit/logout.
# So this gives us constantly appended history, meaning we never lose history lines if the shell dies.
# So we don’t lose history if we lose network connection, or if the system reboots, or if the shell crashes, or for any other reason.
export PROMPT_COMMAND='history -a'
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -a'
alias l='ls -CF'
alias lah='ls -lah'
alias pg='ps aux | grep'
alias psa='ps aux '
alias reset_path='export path=$orig_path'
alias gs='git status'
alias gl='git log '
alias ga='git add '
alias gd='git diff --ignore-space-change '
alias gpl='git pull --rebase'
alias grc='git rebase --continue'
alias gpo='git push origin '
alias gb='git branch '
alias gf='git fetch '
alias gco='git checkout '
alias gca='git commit -a -m '
alias gk='gitk --all & '
alias gg='gitg &'
alias gpsh='git push'
alias gc='git commit -v -m '
alias gba='git branch -a'
alias be='bundle exec '
alias bi='bundle install '
alias bu='bundle update '
alias bil='bundle install --local'
alias gdc='git diff --cached'
alias glp='git log -p'
#rails 3
alias rc='rails console'
alias rs='rails server'
alias rdb='rails db'
export PATH=~/bin:$PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment