Back to Article Listing

Fancy command prompt

Table of Contents


I have friends who are very well respected sysadmins. They roll their eyes at my fancy prompt. And, I could not care less. I like customizing my environment and my fancy prompt helps me.

The information I want to see at the prompt is:

  • who I am
  • what box I am on
  • where I am in the fs
  • date and time

That may seem like a lot if junk at the prompt, but I found that I rely on it; and copy my .profile around to all my boxen. Because vertical space is much more valuable than horizontal space, I include a line return and start from the same spot every time. The OpenBSD default shell is ksh. But, the specifics mentioned here should work in any shell on any unixy OS with only minor changes... I think the time variables my differ on other OS's.


In ksh, I put all my tweaks into the ~/.profile.

Aliasing: I like showing detail on the ls command. I do not like backup file generation in my editor. And I like a clean screen when I exit.

alias ls="ls -alFh"
alias mg="mg -n"
alias exit="clear && exit"

I like a pretty big history file. I have plenty of disk space and it has helped me in the past.


Here is the good stuff! (see sample output below)

export PS1="\e[0;0;34m[\u@\h \D{%a %I:%M %p}] \e[1;34m\w\e[0;0m->"

Other useful exported environment variables

export EDITOR=mg
export PATH=" ..normal path stuff here.. "
export PGHOST="/var/www/tmp/"
export CVSROOT=" local cvs stuff here.. "
export CVS_RSH="/usr/bin/ssh"

I use something similar for root. But I change "34m" to "31m" in the first part of the PS1. That way, when I am root, the prompt is red.

The prompt in action


[myuser@boxname Sun 04:57 PM] ~/notes/articles/working


Copyright © 20070623 genoverly
(db datestamp: 20070821)

Copyright © 2003-2015 genoverly