Subversion and the bash prompt

I recently found this entry that shows how you can update your PS1 value to display certain information about your git workspace.  I don't get to use git too much right now, but I use subversion a lot and wondered what there was for that.  I didn't find anything in the bash-completion entries for svn (though I admittedly didn't look too hard) so I whipped up my own solution late last night. One slight disclaimer before seeing the script:  it was late when i wrote this.  There doesn't appear to be any noticeable performance hits other than the initial run of this script but I make no guarantees.  I'm sure it could be optimized but it's snappy enough and might prove to be mildly useful.  It was interesting enough at midnight at least.  :)  Anyway, the code!

#! /bin/sh
extract() {
	TEXT=$( svn info | grep "$1" )
	echo ${TEXT##$1}
}

if [ -e .svn ]
then
	URL=`extract "URL: "`
	REPROOT=`extract "Repository Root: "`

	echo "\n\033[01;33m[svn: ${URL##$REPROOT}] \033[01;34m"
fi

This can be displayed in your command prompt by setting your PS1 variable like this:

export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w $(svn_ps1)\$\[\033[00m\] '

The single quotes are important there to prevent immediate execution of the script. If you use double quotes, it will be evaluated immediately and your prompt won't update as you navigate around. You only need to save the first script as svn_ps1 somewhere on your PATH or name it as you wish and update the PS1 variable accordingly. You can, of course, specify the full path in the PS1 var if you'd like. This setting will put the path within the current subversion repository in yellow text on a new line. If you're not in a subversion workspace, your prompt is unaffected. I had some code in there to strip off the relevant portions of the cwd from that display so you essentially only saw what branch or tag you were or if you were in trunk. With the script as it is, there's some redundancy between the subversion info display and the cwd shown, but I can live with that.

I switch between branches and even version control systems often enough that i'll probably expand on this to work for git/svn/hg/cvs accordingly. Next time I'm up late hacking.

IDEA 8 on Java 6 on the Mac

That's a lot of "ons" for just a title but it's descriptive at least.  I've been having some problems launching IDEA 8 on my macbook pro since upgrading to 8.0 final (the RCs were fine strangely enough).  I tracked it down to a plugin that had been built against Java 6.  Unbeknownst to me, IDEA 8 is hard coded to launch with Java 5.  I have no idea (ha!) why but I know how to fix it. If you open up the package contents (right click, show package contents) and open the "Contents" folder you'll see a file called Info.plist.  Edit this file with your favorite editor and change the line that says "1.5*" to say "1.6*"  You'll also need to update the JVMArchs entry to list x86_64.  Save the file (but don't close it in case you need to roll back this change) and start IDEA.  When it's done starting up, click on the "Intellij IDEA" title in the menu bar and select "About InteliiJ IDEA" option.  The window that pops up should now list your VM as some 1.6 variant.

Now, I'm sure that JetBrains had some good reason for tying to IDEA to 1.5.  This change might break something down the line.  I haven't used it enough to see if I hit anything like that but so far so good.  Your milage may vary and, of course, I can't guarantee this won't trash your source files.  But it seems to work so far.  If you run into any issues, please leave a comment and tell me about it.  I'm guessing if we run into anything it'll be some odd swing bug.  Good luck with it.

UPDATE:

A friend mentioned some menu rendering lag after trying this tip and fixed it by increasing his permgen space.  Another pointed out the VMOptions IDEA plugin to help with editing those options.  No more tracking down that file.