Skip to content

Instantly share code, notes, and snippets.

@unixmonkey
Created May 19, 2010 22:45
Show Gist options
  • Save unixmonkey/406950 to your computer and use it in GitHub Desktop.
Save unixmonkey/406950 to your computer and use it in GitHub Desktop.
.profile - shortcuts and bash settings
# *****************************************
# .profile
#
# Includes lots of nice funtions
# and aliases to make your command-line
# experience happy and productive
#
# *****************************************
# Me and you; we have history, you know?
HISTCONTROL=erasedups
HISTSIZE=100000
shopt -s histappend # when your shell exits, its history is appended to the .bash_history file
#export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
export PERL5LIB=/Applications/XAMPP/xamppfiles/lib/perl5
# set editor preferences
export EDITOR='mate -w'
export SVN_EDITOR='mate -w'
export GIT_EDITOR='mate -w'
# super happy fun prompt showing server name and current directory with purdy colors
export TERM=xterm
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PS1='\[\e[36m\]$(rvm-prompt i v g) \[\033[0;35m\]iFruit\[\033[0;33m\] \w\[\033[00m\]: '
# Make ruby faster by tuning the garbage collector
export RUBY_HEAP_MIN_SLOTS=500000
export RUBY_HEAP_SLOTS_INCREMENT=250000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=50000000
export RUBY_HEAP_FREE_MIN=500000
# Shortcuts
alias code='cd ~/code'
alias shit='csshx root@iceman root@cyclops root@mystique'
alias b='bundle exec'
autopatch() {
git format-patch HEAD~1
for SERVER in 'iceman' 'cyclops' 'mystique'; do
echo "Sending patch to $SERVER"
scp *.patch root@$SERVER:~/intranet
done
shit
}
# GIT aliases
alias git-rm-all='git ls-files --deleted | xargs git rm'
alias gs='git status'
alias gd='git diff'
alias ga='git add'
alias gb='git branch'
alias gl='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr by %C(bold blue)%an%Cgreen)%Creset" --abbrev-commit --date=relative'
alias gco='git checkout'
alias gcm='git commit -m'
alias g{='git stash'
alias g}='git stash apply'
# VIM
alias vim='mvim -v'
alias st='open -a "Sublime Text 2" "$@"'
# RAILS server/console
s() {
if [ -e "script/$1" ]; then
./script/$*
else
rails $*
fi
}
sc() { s console $*; }
ss() { s server $*; }
# search through your history
histfind() {
history |grep "$*"
}
# Use vim for a nice diff tool
vdiff() {
vim -d $*
}
sync_nframe() {
pwd = $(pwd)
hdid ~/code/nframe.dmg
cd /Volumes/nframe/intranet && git pull && cp db/development.sqlite3 /Volumes/nframe/intranet/db/
cd /Volumes/nframe/ror_on_centos && git pull
cd /Volumes/nframe/accpac_reports && git pull
cd $pwd
umount /Volumes/nframe
}
# copy your ssh key to the server for public key authentication
ssh-copykey() {
cat ~/.ssh/id_rsa.pub | ssh $1 "cat - >> ~/.ssh/authorized_keys"
}
# Bash function to find stuff
# $* means take in all arguments
find_in_dir() {
find . | xargs grep $*
}
# uses find to list every file in current directory and
# all subdirectories then counts lines listed
count_files_in_dir() {
find . -name '' -prune -o -print | wc -l
}
# less with syntax coloring provided by
# pygments (python easy-install pygments)
pless() {
pygmentize $1 | less -r
}
rake_route_urls(){
rake routes | sed -e "1d" -e "s,^[^/]*,,g" | awk '{print $1}' | sort | uniq
}
rake_route_paths(){
rake routes | sed -e "1d" -e "s,^[/^]*,,g" | awk '{print $1}' | sort | uniq
}
gemfolder() {
gemdir="$(rvm gemdir)"
if [ -d $gemdir ]; then
cd $gemdir
else
gemdir
fi
}
# don't show 'system' in prompt if using default ruby
rvm_prompt_proper() {
prompt="$(~/.rvm/bin/rvm-prompt i s g)"
if [ $prompt != "ree" ]; then
echo "$prompt "
fi
}
# ===========================================================
# = feature && hack && rake test && ship =
# = http://reinh.com/blog/2008/08/27/hack-and-and-ship.html =
# ===========================================================
# create new named feature branch and switch to it
feature() {
git checkout -b $1
}
# show commits only this feature branch
feature_commits() {
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
echo "Commits in branch \"${CURRENT}\", but not \"master\":"
git log master..${CURRENT} --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset" --abbrev-commit --date=relative
}
# show diff of things in this branch not in master
feature_changes() {
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
echo "Commits in branch \"${CURRENT}\", but not \"master\":"
git diff master..${CURRENT}
}
# rebase the current state of master into the feature branch
# and fast-forward your changes on top of that for easy
# conflict resolution (or avoidance)
hack() {
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git pull origin master
git checkout ${CURRENT}
git rebase master
}
# switch to master and merge the feature changes, then
# change back (in case you want to work more on that feature)
# note: you should run your tests before shipping
ship() {
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git merge ${CURRENT}
git push origin master
git checkout ${CURRENT}
}
# Source RVM (Ruby Version Manager)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
@unixmonkey
Copy link
Author

Fixes to the 'gemfolder' function that takes you to the rvm gemset gem folder if you are using one

@unixmonkey
Copy link
Author

Add committer name to git log compact format

@unixmonkey
Copy link
Author

Get rid of stuff I don't use enough, make ss & sc work on both rails2 & 3 apps, add make_ruby_fast to use REE gc settings

@unixmonkey
Copy link
Author

Move ruby gc exports into main so they always run; and pass all args (not just the first) to ss, sc & histfind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment