Tuesday, October 27, 2009

Tips: extra contextual shell information for multiple environments

On my desktop, I often work on multiple projects at the same time and I am a fan of command line and terminals.

These projects have different environments (e.g. java 1.5 and maven 2.2.1 on one, java 1.6 and maven 2.0.9 on the other one).

In order to have information about the projects quickly available, I display some version information in the terminal title.

I often set up a end.sh script that contains my project specific environment setup.

My [Ubuntu] .bashrc is modified like this:
function versions {
mvn_version=`mvn --version | grep "Maven" | cut -d ':' -f 2`
jdk_version=`mvn --version | grep "Java" | cut -d ':' -f 2`
svn_version=`svn --version | grep "^svn"`

function prompt_extra { echo ""

# If this is an xterm set the title to user@host:dir
case "$TERM" in
export PROMPT_COMMAND_EXTRA=`prompt_extra`

Then my per project environment scripts that look like:

export MAVEN_HOME=/usr/local/lib/apache-maven-2.0.9


function prompt_extra { echo "MVN:$mvn_version JDK:$jdk_version $svn_version"


No comments:

Post a Comment