FuzzyBlog

Scott Johnson / The FuzzyGroup, Feedster / PHP Consulting / Random geeky stuff / I Blog Therefore I Am.

 Friday, May 23, 2003

Minimalist Linux 01: Customizing Your Bash Prompt

I've been meaning to do this for a while -- a themed set of blog entries about a common topic following in the veins of Simon's CSS stuff or Mark's Python stuff.  And the topic that feels right to me is "Minimalist Linux".  I won't claim that these are any big deal at all but just the little things that make stuff easier.  And even if no one else learns anything from it, I'll have documented what I do and what I like which is helpful to me*.  And so ... Let's talk about Bash.

Note: I'm writing this series purely from a minimalist perspective.  I'll talk about the very, very small subset of Linux that I personally use.   I know there is so much more for everything I'm talking about.  I'm choosing to NOT talk about it.  And I'm simplifying a lot.  Bear that in mind -- a lot.  Readers are encouraged to correct me, give comments, etc.

Bash or "Bourne Again Shell" is the basic command shell you see when you login to or ssh into a Linux box.  It looks basically like a blank screen where you type commands to be executed.  The prompt generally shows you the username and maybe the directory.  Now Feedster has just graduated to a 3rd box at Rackspace and just knowing what box I'm in at any time is actually difficult.  I mean a command shell is a command shell is a command shell.  Now I could solve this locally on my personal box but I use lots of boxes -- a Windows desktop, a Linux desktop and 1 of 2 laptops for when I want to code in the living room on the couch (yeah --- its a happening time around here, let me tell you).  So clearly a server side approach is needed.  And all I really need is to customize the shell as follows:

[ servername - username - current directory ]
$ (this is where the commands would go)

Now the per user configuration for Bash is commonly stored in

/home/username/.bash 

So what I did was edited this file (which had nothing in it meaning that the system defaults were used) and add this:

PS1='[H - u - w/ ]n$'

PS1 is the internal Bash variable for the prompt.  H is the full hostname for the machine, u is the username and w is the working directory.  Now I also added a / at the end of it intentionally even though this wouldn't normally be there.  Why?  Well I'm a VI junkie and with character mode VI everything is copyable.  And since you do so much move to this directory, No!  that directory, No over here!, I find that being able to copy it and paste it is really helpful.

After editing this file I had to tell Bash to reload its profile so I typed

source /home/username/.bash

And that reloaded it giving me my new prompt.  And I was happy.

References

A quick Google turned up these:

Footnotes

*You do realize that a huge amount of blogging is about clarifying your own knowledge and setting things down for yourself, don't you?  And with Feedster's ability to search only your own blog, this is very, very useful.

When: 3:35:25 PM  | Permalink:   | comment []  |  IM Me About This   

Good Thing I Don't Need Anything from Homeland Security

I just surfed over to www.dhs.gov looking for their supposed RSS feed.  So (naturally) I tried searching -- damn search engine doesn't even work.  Pathetic.  Good going Tom Ridge.  Keep spending that multi-billion dollar budget wisely.

When: 6:05:27 AM  | Permalink:   | comment []  |  IM Me About This   

The Great Karmic Chicken in the Sky

I'm honestly not superstitious.  I don't carry a rabbits foot, believe in 4 leaf clovers, etc.  Still I'm starting to wonder if I've seriously pissed off the Great Karmic Chicken in the Sky.  Yesterday was a bad day.  I mean a day that I'll remember for years.  And while I won't bore you with details, two salient details, that honestly are just plain funny, jumped out at me

  • The day began with yet another furnace issue resulting in no hot water (I strongly do not recommend Kerivan Heating and Fuel out of Newton, Mass)
  • The day ended with me getting into bed, utterly exhausted, only to feel beneath me a little present from a feline friend of mine*.  And it was not a good present.  I then cleaned up and spend the night on the (crappy) guest bed waking after only 4 hours sleep.

So it was literally bad from beginning to end.  Go figure.  That damn Karmic Chicken has it in for me I tell you.  He / She does.

*Even worse the little b*tch kitty had the nerve to come cuddle with me only an hour later!

When: 5:49:35 AM  | Permalink:   | comment []  |  IM Me About This   

May 2003
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Apr   Jun

Blog Home

Click here to send an email to the editor of this weblog.

Click to see the XML version of this web page.



Search My Blog



All Posts

Powered by:



My Businesses







About Scott Johnson




Books I've Written







BlogRoll



The FuzzyBlog! © Copyright 2003, The FuzzyStuff.
Last update: 6/2/2003; 7:50:40 AM.