The Setup

Some time back I had another failure of a development machine.  While this was quite painful, it prompted me to look at documenting my development environment as an ongoing series on phatness.com.  I'm a fan of details and my setup tends to have many non-standard details... Here they are.


In my ~/.bash_profile:

alias compass_init="compass init --syntax=sass --css-dir=css --javascripts-dir=js"

I quickly found I had bloody knuckles after typing in compass init and getting bunk defaults of SCSS.

 

While there are some great diff tools out there, there are very few good merge tools. My favorite diff tool is Kaleidoscope. And there are several others I wouldn’t mind using.

However, Kaleidoscope does not do merging. Too me, software development requires much more merging then diff’ing. And many times, github.com’s HTML diff view is more than sufficient. Heck, even command line diff works just fine for small differences. Looking at diff’s is easy and paying money for a tool that only does diffs is something I find hard to swallow.
<Read on…>

 

By default, git is colorless. What decade is this again? “Squirt” this crap in your prompt and things will be better.

git config --global color.ui "auto"
git config --global color.branch "auto"
git config --global color.status "auto"
git config --global color.diff "auto"
 

This is one of the best tips if you are developer working with git on the terminal. If you are inside a directory or project managed by git, this will append the working branch your code is on to the prompt!

function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/ [1]/'
}

BOLD=$(tput bold)
RESET=$(tput sgr0)

export PS1="[u@h W][$BOLD]$(parse_git_branch)[$RESET] $ "

The key here is, of course, the bash function created called: parse_git_branch(). Then we are modifying the default bash prompt and including the result via: $(parse_git_branch)

I do like to throw in a little color for the branch. So my actual prompt is:

export PS1="[u@h W]e[0;35m[$BOLD]$(parse_git_branch)[$RESET]e[m $ "
 

The default prompt for bash on Mac OS X is wrong, err, different. I spend a lot of time on linux servers through terminal and like to keep things consistent. Append this to your ~/.bash_profile: to keep things in line with Red Hat:

export PS1="[\u@h \W]\$ "

If you want to get more original, here is a list of codes you can use instead:

  • a : an ASCII bell character (07)
  • d : the date in “Weekday Month Date” format (e.g., “Tue May 26”)
  • D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
  • e : an ASCII escape character (033)
  • h : the hostname up to the first ‘.’
  • H : the hostname
  • j : the number of jobs currently managed by the shell
  • l : the basename of the shell’s terminal device name
  • n : newline
  • r : carriage return
  • s : the name of the shell, the basename of $0 (the portion following the final slash)
  • t : the current time in 24-hour HH:MM:SS format
  • T : the current time in 12-hour HH:MM:SS format
  • @ : the current time in 12-hour am/pm format
  • A : the current time in 24-hour HH:MM format
  • u : the username of the current user
  • v : the version of bash (e.g., 2.00)
  • V : the release of bash, version + patch level (e.g., 2.00.0)
  • w : the current working directory, with $HOME abbreviated with a tilde
  • W : the basename of the current working directory, with $HOME abbreviated with a tilde
  • ! : the history number of this command
  • # : the command number of this command
  • $ : if the effective UID is 0, a #, otherwise a $
  • nnn : the character corresponding to the octal number nnn
  • \ : a backslash
  • [ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
  • ] : end a sequence of non-printing characters
 

On Mac OS X, the Terminal output isn’t colorized by default. Add the following to ~/.bash_profile:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

And uncheck “Use bold fonts” in Terminal preferences under Text. Monaco font in bold looks hideous.

While we are at it, make sure you are using the Pro settings scheme as a default. Which you use is really personal preference, but if you are a beginner, let’s start you off on the right foot with Pro.

 

 

After starting up another Grails project and completely missing my text-to-speech solution for long build times, I decided to do something a little more re-usable.

I just released a Grails plugin that provides this functionality. It’s as simple as: 

grails install-plugin nadd-neutralizer

Right now, only Mac OS X is supported. Patches are welcome for other operating systems. Source code is here: http://github.com/digerata/grails-nadd-neutralizer

 

This is a tip for those of you dealing with long build times, which for me, is anything greater than about 4 seconds 😉

The problem that those of us with NADD face is the second we are waiting for something to finish, we [alt|cmd]+Tab to a browser and start reading slashdot, rotten tomatoes, daringfireball, or any of a million other sites. Likely, you classify this “quick field trip” as multitasking and because you are so very good at multitasking (despite what all the experts say), you disregard the fact that your build was probably finished 10 minutes ago.
<Read on…>

 

Nothing in this world makes less sense then how Apple decided to make Home, End, Page-Up, and Page-Down work.

I’m not sure where, when, and why this started. But on every other modern day operating system, these keys work like this:

- Home -> move the cursor to the beginning of the line
- End -> move the cursor to the end of the line
- Pg-Up -> move the cursor up the length of the viewport
- Pg-Dn -> move the cursor down the length of the viewport

Now I don’t know why I am even repeating these descriptions. As much as the sky is blue and earth is below our feet, everyone knows what these buttons do.

Unless you are on a Mac. <Read on…>