Skip to content

Instantly share code, notes, and snippets.

@harlantwood
Created October 28, 2009 00:43
Show Gist options
  • Save harlantwood/220115 to your computer and use it in GitHub Desktop.
Save harlantwood/220115 to your computer and use it in GitHub Desktop.
bash_profile extensions

Usage: in your ~/.bash_profile, include this line:

export BASH_PROFILE_EXTENSIONS=~/path/to/bash_profile_extensions && . $BASH_PROFILE_EXTENSIONS/load

The extensions load each other. There are currently two main entry points:

  • osx (for Mac dev boxes, includes everything)
  • basics (used for linux servers, includes all except OSX-specific)
# The basics, designed to be safe(ish) for production servers
. $BASH_PROFILE_EXTENSIONS/ruby
alias ls='ls -F'
alias ll='ls -lFh'
alias lla='ls -lFah'
alias llt='ls -lFahrt'
alias ls='ls -F'
alias pd='pushd'
alias pop='popd'
alias d='dirs'
alias a=alias
alias h='history | tail -50'
alias g=git
alias gpp='git pull && git push'
alias ebp='$EDITOR ~/.bash_profile'
alias ebpe='$EDITOR $BASH_PROFILE_EXTENSIONS'
alias sbp='. ~/.bash_profile'
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
# 1 line prompt:
alias p1='export PS1="\\[\\033[37m\\[\\033[44m\\] \\u@\\h \\[\\033[0m\\] \\w \[\033[31m\]\$(parse_git_branch)\[\033[00m\] $\[\033[00m\] "'
p1
# 2 line prompt (with time):
alias p2='export PS1="\\[\\033[32m\\]\\t\\[\\033[0m\\] \\[\\033[37m\\[\\033[44m\\] \\u@\\h \\[\\033[0m\\]\\n\\w \[\033[31m\]\$(parse_git_branch)\[\033[00m\] $\[\033[00m\] "'
# export PS1="\t \u@\h \w $(__git_ps1 \"(branch: %s)\")\n\$" # git branch prompt, currently failing...
# RED="\\[\\033[31m\\]"
# GREEN="\\[\\033[32m\\]"
# YELLOW="\\[\\033[33m\\]"
# BLUE="\\[\\033[34m\\]"
# WHITE="\\[\\033[0m\\]"
# export PS1="$RED\\! $GREEN\\t $RED\\u@\\h $WHITE\\w \$ "
# export PS1="$RED\u@\h $WHITE\! $GREEN\w $ $WHITE" # alternate version, no time
# remove all .svn dirs in the current dir and subdirs
alias rmsvn='find . -name ".svn" -exec rm -rf "{}" \;'
alias rmds='find . -name ".DS_Store" -exec rm -rf "{}" \;'
# everyone needs Jeckyll, right?
alias jek='rm -rf _site && jekyll --pygments'
alias jeks='rm -rf _site && jekyll --pygments --server 4000 --auto'
. $BASH_PROFILE_EXTENSIONS/osx
. $BASH_PROFILE_EXTENSIONS/custom
# For an OSX development box -- we get everything used on servers, and mac specific stuff as well
. $BASH_PROFILE_EXTENSIONS/basics
export PATH="~/bin:/usr/local/mysql/bin:/opt/local/bin:/usr/sbin:$PATH"
export MANPATH=$MANPATH:/opt/local/man
export EDITOR=/usr/bin/mate
# open Textmate with only the dirs we normally want to work with
alias matey='mate `ls -Fa | grep -v .git/ | grep -v .DS_Store | grep -v _site/ | grep -v doc/ | grep -v log/ | grep -v public/ | grep -v tmp/ | grep -v vendor/ | grep -v "\./"` public/javascripts public/stylesheets'
alias mater=matey
alias gdm='git diff HEAD | mate'
# Ruby
# OSX / ruby 1.8 specific, change to your gem dir:
GEMS_DIR=/Library/Ruby/Gems/1.8
alias gems='cd $GEMS_DIR/gems'
alias gemdoc='cd $GEMS_DIR/doc'
# Bundler
alias bi="bundle install --without production --path=~/.bundler/PROJECTS/\${PWD##/*/}/.bundle/_bundle"
alias be='bundle exec'
# Rails
alias r='be rails'
alias ss='script/server'
alias sc='script/console'
alias sg='script/generate'
alias sp='script/spec --color --loadby mtime --reverse'
alias spb='sp -f b'
alias rdm='rake db:migrate'
alias rdp='rake db:prepare'
alias rdr='rake db:rebuild'
alias rtp='rake db:test:prepare'
alias au='be autospec'
alias auf='AUTOFEATURE=true au'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment