This is the first part of a series where I’ll walk through the dotfiles I use to make my day-to-day work easier and more enjoyable.
I use Git and Rails every day. To save my fingers from unnecessary wear, I’ve created short aliases for the commands I type most often.
Stick these in ~/.aliases:
# ~/.aliases
# Record how much I've used various Git commands:
# http://github.com/icefox/git-achievements
alias git="git-achievements"
# Working with Git
alias g='git'
alias gs='git status'
alias gc='git commit'
alias gca='git commit -a'
alias ga='git add'
alias gco='git checkout'
alias gb='git branch'
alias gm='git merge'
alias gd="git diff"
# Working with Rails
alias s='script/server'
alias c='script/console'
alias m='rake db:migrate'
alias r='rake'
# Open the current directory in TextMate
alias e='mate .'
# Serve the contents of the current directory over HTTP
alias serve="ruby -rwebrick -e\"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start\""
The git-achievements alias wraps the real git binary with git-achievements, which tracks how often you use various Git commands. It’s a fun little motivator.
The serve alias is surprisingly handy – it spins up a quick WEBrick server on port 3000 serving whatever’s in your current directory. Great for previewing static sites or sharing files on a local network.
Now source the aliases file from your ~/.profile so they’re available in every session:
# ~/.profile
for I in aliases; do
[ -f ~/.$I ] && . ~/.$I
done
The loop might look like overkill for a single file, but it scales nicely as you add more dotfiles to the pattern – just append their names to the list.