Sunday, January 20, 2008

My Custom Prompt for Leopard's Terminal

As I mentioned in my previous post, even though it is not perfect, I settled on using Terminal as my terminal application.

The default prompt that comes with MacOS is not very useful, so I configured my own by adding this line to my .bashrc file:
export PS1="\[\033]0;\u@\h:\w\007\]\u@\h:\W\\$ "

This results in a prompt that looks like this:

This prompt displays the prompt as username@hostname:currentdir$ and in addition to that it sets the window title to username@hostname:pwd.

2 comments:

Shawn Ferry said...

You can see (almost) my significantly more solaris centric zsh prompt (on my mac I drop the zone info)

if [ -x /usr/bin/zonename ]
then
export zone=`/usr/bin/zonename`
else
export zone="notzone"
fi



export prompt="[%n@%m(%?) %T %l] {$zone}
%/
[%h] "



[sferry@7cit001ua(0) 13:19 pts/59] {notzone}
/export/home/sferry
[26]

I find that I have sessions on diverse hosts such that the extended info is a necessairy evil.

fikovnik said...

I kind of like colors so beginning of my .bashrc:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

case "$TERM" in
xterm*|rxvt*)
# see more at http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
# set prompt to [user@host:dir]$
PS1="\[\e[1;37m\][\u@\h:\[\e[0m\]\[\e[1;34m\]\W\[\e[0m\]\[\e[0;37m\]]\$\[\e[0m\] "

# so colors are in sync with ls LSCOLORS="Exfxgxhxcxbxcxcxdxdx"
export LSCOLORS
;;
*)
PS1='\u@\h:\w\$ '
;;
esac