Jan 4, 2010

Exactly how is your development environment configured?

Along with Grails we are seeing a resurgence of the shell and the command line. And if there is anything experienced unix users hate, it’s asking a newbie how their environment is configured and getting a blank stare in return. Well I solved this problem years ago with a simple shell script — it’s time to resurrect printconfig. A call to printconfig shows the path and a subset of the shell’s environment variables. For example:

yaal.local[525]> printconfig
HOME		/Users/amiller
ANT_HOME	/Users/amiller/devtools/ant/current -> ant-1.7.1
CATALINA_HOME	/Users/amiller/devtools/tomcat/current -> tomcat-6.0.16
EMACS_HOME	/Users/amiller/devtools/emacs/carbon-emacs-22.3.1_2009.07.25.app
GRAILS_HOME	/Users/amiller/devtools/grails/current -> grails-1.2.0
GROOVY_HOME	/Users/amiller/devtools/groovy/current -> groovy-1.6.7
IVY_HOME	/Users/amiller/devtools/ivy/current -> ivy-2.1.0
JAVA_HOME	/Users/amiller/devtools/jdk/current -> jdk-1.6.0
JBOSS_HOME	/Users/amiller/devtools/jboss-4.0.5
MAVEN_HOME	/Users/amiller/devtools/maven/current -> maven-2.0.9
TOMCAT_HOME	/Users/amiller/devtools/tomcat/current -> tomcat-6.0.16
ANT_OPTS	-Xmx128m
JAVA_OPTS	-Xmx512m
MAVEN_OPTS	-Xmx2100m -Xms512m
PATH=.
     /Users/amiller/bin
     /Users/amiller/devtools/ant/current/bin
     /Users/amiller/devtools/emacs/carbon-emacs-22.3.1_2009.07.25.app/bin
     /Users/amiller/devtools/grails/current/bin
     /Users/amiller/devtools/groovy/current/bin
     /Users/amiller/devtools/jdk/current/bin
  ...

(See my post on Fast path switching between projects for an explanation of the “current” path elements.)

Call printconfig from the last line in your .profile and your new user shells will always show the environment as it is configured. Try it next time you’re debugging a shell’s environment and let me know what you think.

The printconfig script:

#!/bin/sh
#
# Echo some config info at shell startup time
# (useful when debugging the shell environment.)
#
# Preserve the intentionally HARD_TABS when editing!
#
echo "HOME		$HOME"

for home_var in `printenv | grep _HOME | sort`; do
    home_var_name=`echo $home_var | awk -F= '{ print $1 }'`
    home_var_value=`echo $home_var | awk -F= '{ print $2 }'`
    if [ -h $home_var_value ]; then
        # echo out what symbolic links are pointing to...
        echo "$home_var_name	`ls -l $home_var_value | awk '{ printf "%s -> %sn", $9, $11 }'`"
        #                   ^ hard tab
    else
        echo "$home_var_name	$home_var_value"
        #                   ^ hard tab
    fi
done

printenv | grep _OPTS | sort | sed 's/=/	/'
#                                       ^ hard tab

echo "PATH=$PATH" | sed 's/:/
     /g'

About the Author

Object Partners profile.

One thought on “Exactly how is your development environment configured?

  1. Josh Brown says:

    This is really cool – thanks for posting!

  2. Lukas Rossa says:

    Yes, Grails is great but it’s quite unfortunate that the tool support is still far behind mature languages such as Java and C# and we’re having to revert back to command line..
    I think this is the most annoying thing about new languages in general – they may be less verbose and do things smarter, you spend so much more time with basics such as project setup and environment and plugin configuration and test setup / running and wondering what was that command again to do XYZ.. because the IDE doesn’t do it yet…
    I’m looking towards the SpringSource Tool Suite to address this soon.
    Anyways, this is just my rant – thanks for this post.

Leave a Reply to Lukas Rossa Cancel reply

Your email address will not be published. Required fields are marked *

Related Blog Posts
Google Professional Machine Learning Engineer Exam 2021
Exam Description A Professional Machine Learning Engineer designs, builds, and productionizes ML models to solve business challenges using Google Cloud technologies and knowledge of proven ML models and techniques. The ML Engineer is proficient in all aspects […]
Designing Kubernetes Controllers
There has been some excellent online discussion lately around Kubernetes controllers, highlighted by an excellent Speakerdeck presentation assembled by Tim Hockin. What I’d like to do in this post is explore some of the implications […]
React Server Components
The React Team recently announced new work they are doing on React Server Components, a new way of rendering React components. The goal is to create smaller bundle sizes, speed up render time, and prevent […]
Jolt custom java transform
Jolt is a JSON to JSON transformation library where the transform is defined in JSON. It’s really good at reorganizing the json data and massaging it into the output JSON you need. Sometimes, you just […]