I come from a Unix backbround and use a lot of X11 only apps in my daily work, so I was pretty excited when Apple released X11 for OSX and has now included it with Panther. What follows are a couple of changes to bash's startup scripts (this applies to Panther users only, unless you change your default shell to bash on 10.1 or 10.2) to make using X11 apps more convenient from Terminal.app.
Read the rest of the hint for the changes...
First, a simple change to ~/.bashrc (since Apple included X11, but didn't add the X11 apps to the default PATH):
PATH=${PATH}:/usr/X11R6/bin
export PATH
Then, a whole lot of changes to ~/.bash_profile:
# source .bashrc if it's there
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# if we're NOT ssh'd in
if [ ! ${SSH_TTY} ]; then
# make sure X is running
if [ "x`ps -x | awk '{print $5}' | grep X11`" = "x" ]; then
open /Applications/Utilities/X11.app
# then refocus Terminal.app
osascript << EOF
tell application "Terminal"
activate
end tell
EOF
fi
# if DISPLAY isn't set
if [ x${DISPLAY} = x ]; then
export DISPLAY=:0
fi
fi
# I like ls to color code my files
export CLICOLOR=1
What we do here is first check that this is not a remote ssh session. I tend to use a lot of X11 apps over ssh connections using ssh's built-in X11 forwarding. So, if I'm ssh'd in, I don't want to start up X, since I won't be displaying locally, it doesn't matter. I also don't want to clobber DISPLAY, since ssh sets up it's own DISPLAY variable for tunneling (generally localhost:10).
Mac OS X Hints
http://hints.macworld.com/article.php?story=20031026091804549