Friday, June 30, 2006

FreeBSD Customized Shell Prompt


This posting is to track my progress with customizing my shell prompt. From time to time I like to delve into some aspect of my computer and do as much with it as I can. My favorite OS is FreeBSD, and as such I find myself using the C Shell quite often. I also spend a lot of time in the command line. This being said, I have had the need to know a little about my environment while I work. Prompted by a very lavish and colorful BASH prompt from a friend of mine, I set out to customize my C Shell to fit my personal needs.

I started by figuring out what information I wanted in my prompt. The list looked something like this:

1-current user and host
2-date
3-time
4-current directory

On top of this, based on my friends prompt, I wanted this information above my cursor so as not to waste space for long directories. I have seen prompts like this on many flavors of Linux, however FreeBSD does not come like this by default.

My first attempt looked something like this:

%vi .cshrc

....
set prompt = '%n@%m:%/%# '
....

which looked something like this: eon@ZETA:/home/eon>

Next I added a Grey color to my prompt:

eon@Zeta:/home/eon>vi .cshrc
....
set prompt = '%{\033[37m%}%n@%m:%/%# '
....

Next I applied these changes to my root account, making the prompt red. Note: This line must be added to the end of the .cshrc script.

set prompt = '%{\033[31m%}%n@%m:%/%# '

Making my regular user Grey and my root account red is an easy way to determine what user I am. On many occasions I have been on my BSD laptop and sshed into my home box and issued a "init 0" command to shut my Laptop down inadvertently bringing down my server at home. Smart ay! This way I make my root user on my home box red so I know when I am sshed in as opposed to local. :)

Next I set out to complete my prompt. To make a log posting short, this is what I ended up with in my ".cshrc" script:

set prompt = '\n%{\033[37m%}%n@%m:%/\t[%D-%w-%y %t]\n%# '

This adds a new line to separate the previous output, color, user@host, current directory, and tabs to a Day-Month-Year Time output, and newlines to the prompt. It looks something like this:

eon@ZETA:/home/eon [30-Jun-06 10:42pm]
>

or as root:

root@ZETA:/root [30-Jun-06 10:43pm]
#

This currently fulfills my needs. Any new additions/updates will be posted here.

Monday, June 26, 2006

Up and running!


This is the debut of my blog on blogger.com. I will use this as a forum to post and publish my works and thoughts. Enjoy!

<---btw... Me at the step pyramid at Sakkara