Ubuntu Server 8.04 Post Install Tip #2: Shell Goodies

OK, I promised a friend some time ago that I’d post all of my post-install procedures and I’ve not quite followed through with that so I’m doing a few before finishing up my three part post on the “Home Hacker’s Network”. These are all just little hacks I’ve come across and modified to suit my needs. I like this one a bunch as it gives me a nice shell prompt when I login as well as when I use screen (although the gnu screen configuration part is mutually exclusive to the shell modification part).

So lets get started…

I got this nice prompt script from http://www.iml.ece.mcgill.ca/~stephan/bash_pompt

nano ~/myprompt.env

Add the following and save

A quick note here, the prompt is defined by the last statement starting at PS1=, you can change this as you see fit, the “\” is an escape character and will be needed at the end of every line. the author conveniently defined all the colors at the top of the script. Typical bash escape characters apply so \h = hostname of machine and \u = username. Uncomment the first 4 lines of PS1 and remove the second PS1 line to add the time at the beginning of the prompt.

Fix up your bash profile by sourcing the above file at each login and by adding a few more sysadmin type paths.
nano ~/.bash_profile
add the following and save:
export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/share
source ~/myprompt.env

Note: Ok, the previous instructions work just fine on a headless system which, consequently, is what I base my write-ups on. But to be true to the rules of bash you should actually put the previous code at the end of ~/.bashrc

Now make screen act a bit nicer when you open new screens (if, that is, you use screen like every good geek should do)

sudo apt-get install screen
sudo nano /etc/screenrc

Add this at the very end:
# make the shell in every window a login shell
shell -$SHELL

explanation:Screen does not source .bash_profile by default as a new screen is not a new login screen but just a derivative of the current running screen. This fixes that so we have nice paths and prompts with new windows in screen. If you are a hard core screen user you can do other things like set it up to start up multiple screens and run a program in each one when you start up screen. Maybe more on that later?

Comments (1)

  1. 3:57 PM, 01/20/2012junk car  / Reply

    Aw, this was a really nice post. In idea I would like to put in writing like this additionally – taking time and actual effort to make a very good article… but what can I say… I procrastinate alot and by no means seem to get something done.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pingbacks (0)

› No pingbacks yet.


Get every new post delivered to your Inbox

Join other followers