Sensible Open Source

Blog Status

  • 4 yrs 33 wks 5 days old
  • Updated: 26 Nov 2009
  • 438 entries
  • 168 comments
Total: 1,103,242
since: 5 Apr 2005

LinkBlogS

Creating Vidcasts

18 June 2007, Monday 7:05 P GMT-06
Tags:      

Man, Can't Microsoft Catch A Break?

16 March 2007, Friday 12:26 P GMT-06

Viacom, Google andYou Tube, Oh My!

16 March 2007, Friday 12:25 P GMT-06

Switch to digital TV to start in October

16 March 2007, Friday 7:46 A GMT-06

Is the Ice Ready? No, Its Still To Hot To Use...

16 March 2007, Friday 7:43 A GMT-06

MIT Entire Curriculum At disposal of e-learners

6 March 2007, Tuesday 11:52 A GMT-06

A cure for e-mail attention disorder?

2 March 2007, Friday 12:51 A GMT-06
Tags:  

Windows-on-Mac software gets virtualization update

1 March 2007, Thursday 5:08 A GMT-06

EnterpriseDB is/n't Open Source

1 March 2007, Thursday 3:37 A GMT-06

BitTorrent download portal debuts

27 February 2007, Tuesday 9:05 A GMT-06

$45b TXU buyout

27 February 2007, Tuesday 9:02 A GMT-06

iPhone Competitors Got The Touch

26 February 2007, Monday 3:43 A GMT-06
Tags:        

HTC - Smart Mobility

25 February 2007, Sunday 4:22 A GMT-06

Hard to find 1-800 numbers

23 February 2007, Friday 8:35 A GMT-06

Cuba Embraces Open-Source Software

21 February 2007, Wednesday 3:10 A GMT-06

Vista at the tipping point, Err Dipping Point?

11 February 2007, Sunday 11:11 A GMT-06
Tags:  

PostgreSQL Open Source And Persistence

3 February 2007, Saturday 10:32 P GMT-06

Blackboard Pledges No Patent Blocks

3 February 2007, Saturday 10:28 P GMT-06

UVU

5 January 2007, Friday 11:58 P GMT-06

Open-source IP PBX software appliance"

4 January 2007, Thursday 3:44 A GMT-06

Asterisk an under-appreciated Open Source Success Story

4 January 2007, Thursday 3:43 A GMT-06

Open Source AJAX Tooling

4 January 2007, Thursday 3:41 A GMT-06

Google MAIL API Secuirty Alert

1 January 2007, Monday 7:37 P GMT-06
Tags:    

United States Patent Application: 0060288329

26 December 2006, Tuesday 4:00 A GMT-06

LinkBlog Popular Tags

                                       







««Nov 2009»»
SMTWTFS
123
4
567
8
9
1011121314
15161718
19
20
21
2223
24
25262728
2930

 

August 16, 2012

Time Left

2 years 8 months 15 days

                   

New Design: RedTie by alexisc22

24 May 2009, Sunday
alexisc22's "RedTie" was just added to OSWD! It is white and red and validates XHTML 1.0 Transitional.

New Design: Simple Beauty by dboy

24 May 2009, Sunday
dboy's "Simple Beauty" was just added to OSWD! It is white and gray and validates XHTML 1.0 Strict.

New Design: Rounded_2 by jedignork

24 May 2009, Sunday
jedignork's "Rounded_2" was just added to OSWD! It is blue and white and validates XHTML 1.0 Strict.

New Design: Delicious Fruit by Dieter

24 May 2009, Sunday
Dieter's "Delicious Fruit" was just added to OSWD! It is yellow and green and validates XHTML 1.0 Strict.

New Design: Touching by timmytima

24 May 2009, Sunday
timmytima's "Touching" was just added to OSWD! It is white and black and validates XHTML 1.0 Transitional.

New Design: BlackandGreen by shipping_guy

24 May 2009, Sunday
shipping_guy's "BlackandGreen" was just added to OSWD! It is orange and green and validates XHTML 1.0 Strict.

New Design: Sundark by rotw

24 May 2009, Sunday
rotw's "Sundark" was just added to OSWD! It is black and yellow and validates XHTML 1.0 Transitional.

New Design: Cash by alexisc22

24 May 2009, Sunday
alexisc22's "Cash" was just added to OSWD! It is green and gray and validates XHTML 1.0 Transitional.

New Design: Greeny blu by heartlessg

24 May 2009, Sunday
heartlessg's "Greeny blu" was just added to OSWD! It is black and blue and validates XHTML 1.0 Transitional.

New Design: Cloudy Water Sports by boilers

24 May 2009, Sunday
boilers's "Cloudy Water Sports" was just added to OSWD! It is gray and blue and validates XHTML 1.0 Strict.

This week at LWN: On GNOME and its Foundation: an interview with Luis Villa

24 May 2009, Sunday
LWN recently posted a brief article on the GNOME Foundation's plea for support to help it get through a difficult year. Some of the comments on that news questioned the role of the foundation and its

Poseidon USB Stack Bounty Reached: Open Source, AROS Port

24 May 2009, Sunday
Another important bounty quota has been reached in the Power2People website, and this time the result comes from a common effort of the whole Amiga/Morphos/AROS Community. The result of this bounty be

Where to buy Preinstalled Linux Laptop/Desktop

24 May 2009, Sunday
Installing any OS can still sometimes be a tedious task and one that scares the wits out of the average computer user. And, it’s just more fun to buy a computer with Linux already on it and not have t

Microsoft and ODF: Bad for Everyone

24 May 2009, Sunday
Microsoft finally agreed to implement ODF support in Microsoft Office, but they didn't do it quite right, hurting both Microsoft and the ODF specification.

Linux MMORPG Game Engine Sees Major Update

23 May 2009, Saturday
Regnum Online, a Massively Multi-player Online Role Playing Game that has a native Linux client offered by its developers (NGD Studios), has received a major overhaul. Regnum Online is one of the very

Discovery: The Ultimate Linux Device - The Kickfire Appliance

23 May 2009, Saturday
Discover the Kickfire appliance--if this isn't the ultimate Linux device, one might not exist.

Some Funny Linux/Computer Pictures

23 May 2009, Saturday
More funny pictures from the "world wide interweb" - I think that's what Mr. Monk calls it ;)

The Acer Debacle - Closing the Chapter

23 May 2009, Saturday
Michelle Minkin, a friend of this effort and an all-around nice lady; suggested that we auction off the opportunity to destroy these computers. We were almost ready to start soliciting the community f

Cisco Settles, But Where From Here?

23 May 2009, Saturday
Until September 20, 2007, nobody had ever sued anybody for violating the General Public License (GPL) — not a single company, project, or individual developer in the license's then-eighteen

OpenBSD 4.5 update: Reinstall goes quickly, X still in trouble; still running Ubuntu 8.04

23 May 2009, Saturday
I'll keep this quick. I followed the advice of Nathan from OpenBSD101 and replaced my upgraded OpenBSD 4.5 installation with an entirely new, reinstalled system. That took all of 10 minutes. I followe

Desperation, Scare Tactics, and Happy Memorial Day!

23 May 2009, Saturday
I love to poke fun at tech vendors who continually boast of their innovation, when in fact they're scared to death of real innovation, if they could even recognize it. Today I poke fun at the anti-mal

RSS Add-Me








Google Related Links

MAC OS X : BASH Customize Your Terminal Prompt; A little Color, Invoke A Script & Other Prompt Options

posted 12 February 2006, Sunday
Ever go into the MAC OS X Terminal?  Do you have BASH? If you don't and need a tutorial on BASH try this link!

Now, if you are new to BASH or have experience with BASH the PROMPT is very useful for information that can be conveyed to the user about the date/time, login id, jobs running and several other options.  Furthermore, the prompt can be set to display colors to highlight prompt areas to vividly display this information to the user.

Lets start out with describing the Prompt Environment value:

Simply, PS1 and PS2 are prompt environment values that MAC OS X BASH uses (alot of this applies to other UNIX systems and the knowledge here can be transferred to Linux, HPUX, etc without very little change, if any) to customize how the terminal displays the prompt to the user.  PS1 & PS2 are primary and secondary prompts!    PS1's purpose as the primary prompt is to request commands from the user. The secondary prompt's purpose is to take further input from a command invoked from a PS1 prompt that request additional information.  An example of a PS1 prompt is listed below:



The prompt above represents the PS1 environment  variable.  Let's disect the prompt to understand how this was customized:
<Helios:sparc> 0 [02-12 08:57] ~ (0 Mb)
!




The first character is "<" in fact "<" & ">" are just that and are used as a visual representation of highlighting the information being conveyed.  This is also the purpose of these characters "[", "]", (" & ")", "!" and ":" through out the prompt.  

Helios is the HOST name of the computer

":" colon is a character to seperate the Host from the User ID (Personal Preference)

sparc is the user id.

The 0 is the number of jobs the user has running in the background.

The Date & Time is self explanatory.

is the current directory

O Mb is the total amount of bytes representing all the files in the current directory.

There is the format of this customized prompt, now
PS1="\n<\[\033[0;32m\]\h\[\033[0m\]:\[\033[0;37m\]\u\[\033[0m\]> \j [\$(date +%m-%d\" \"%H:%M)] \w (\[\033[0;36m\]\$(/Users/sparc/bin/TBytes.sh) Mb\[\033[0m\])\n! "
lets see the anatomy of this prompt and how the customization is achieved.






The above line is first put into .profile in the user directory.  This allows the prompt to persist from session to sesson.

\n is simply requesting a new line.

< just a character

\[ starts NON-PRINTING characters (Prepares to request color change)

\033[ escape sequence

0 uses default attribute [0 portion] for bold, underscore etc.

;32m sets the color

\] Ends the NON-PRINTING characters

The entire command is \[\033[0;32m\] Turns font color to blue

/h is the host

/u  user

(date +%m-%d\" \"%H:%M) Turns font color to white

\$ Expands to the process ID of the shell.  In a  ()  subshell,  in this case the date command is invoked to retrieve current Month/Day/Hour/Minute as seen below:

(date +%m-%d\" \"%H:%M)

\w   current working directory (pwd)

\$(/Users/sparc/bin/TBytes.sh) is another subshell request to a script file that reads the number of bytes used by the files in the current directory.  The script is below:

! cat ~/bin/TBytes.sh
#!/bin/bash
#Sum the number of bytes in a directory listing
TBytes=0
for Bytes in $(ls -l | grep "^-" | awk '{ print $5 }')
do
    let TBytes=$TBytes+$Bytes
done
TotalMeg=$(echo -e "scale=3 \n$TBytes/1048576 \nquit" | bc)
echo -n "$TotalMeg"





















\[\033[0m\] 
This sequence puts the font color back to the original prompt color

\n
New Line

!
Character to present for prompt user for input.

The following escape sequences and decodings are below:



\a

 an ASCII bell character (07)

\d

 thedatein "Weekday Month Date" format (e.g. Rue May 26)

\D{format}

 

 

the format is passed to strftime(3)andtheresultis

 

insertedinto the prompt string; an empty format results

 

 in a locale-specific time representation.The braces are

 

 required

\e

 an ASCII escape character (033)

\h

 the hostname up to the first `.'

\H

 the hostname

\j

 the number of jobs currently managed by the shell

\l

 the basename of the shell's terminal device name

\n

 newline

\r

 carriage return

\s

 thenameof the shell the basename of $0 (the portion  following the final slash)

\t

 the current time in 24-hour HH:MM:SS format

\T

 the current time in 12-hour HH:MM:SS format

\@

 the current time in 12-hour am/pm format

\A

 the current time in 24-hour HH:MM format

\u

 the username of the current user

\v

 the version of bash (e.g. 2.00)

\V

 the release of bash version + patchelvel (e.g. 2.00.0)

\w

 the current working directory

\W

 the basename of the current working directory

\!

 the history number of this command

\#

 the command number of this command

\$

 if the effective UID is 0 a # otherwise $

\nnn

 the character corresponding to the octal number nnn

\\

 a backslash

\[

 begin a sequence of non-printing characters which could

 

 beusedtoembeda terminal control sequence into the

 

 prompt

\]

 end a sequence of non-printing characters

 

 PS1='[\u@TEST \w]\n \#\$ \n\

\[\

 end a sequence of non-printing characters




 

\e[1mBold Text\e[m\n\

 

\e[4mUnderline Text\e[m\n\

 

\e[5mBlink Text\e[m\n\

 

\e[7mInverse Text\e[m\]\n\

 

Should be normal text

 

Foreground colors:

 

\[\

\e[0;30m

 Black\n\

\e[0;31m

 Red\n\

\e[0;32m

 Green\n\

\e[0;33m

 Yellow\Orange\n\

\e[0;34m

 Blue\n\

\e[0;35m

 Magenta\n\

\e[0;36m

 Cyan\n\

\e[0;37m

 Light Gray\Black\n\

\e[0;39m

 Default\n\

Bright foreground colors:

 

\e[1;30m

 Dark Gray\n\

\e[1;31m

 Red\n\

\e[1;32m

 Green\n\

\e[1;33m

 Yellow\n\

\e[1;34m

 Blue\n\

\e[1;35m

 Magenta\n\

\e[1;36m

 Cyan\n\

\e[1;37m

 White\n\

\e[0;39m

 Default\n\

Background Colors

\e[m\]

\[\e[1;37m\e[40m:

 Black\e[0;49m\n\

\e[41m:

 Red\e[0;49m\n\

\e[42m:

 Green\e[0;49m\n\

\e[43m:

 Yellow\Orange\e[0;49m\n\

\e[44m:

 Blue\e[0;49m\n\

\e[45m:

 Magenta\e[0;49m\n\

\e[46m:

 Cyan\e[0;49m\n\

\e[47m:

 Light Gray\Black\e[0;49m\n\

\e[49m:

 Default\e[m\]\n'



There you go!

For more detail information from the terminal you can issue "man bash"

tags:        

links: digg this    del.icio.us    technorati    reddit




1. Klaus Wik left...
1 March 2007, Thursday 1:39 am

When you drag awk into it, why bother with grep and for? awk does it all:

TBytes = #ls -l | awk 'BEGIN {sum=0} /^-/ {sum+=$5} END {print sum}'#

Replace # with a grave accent. Apparently I am blogically challenged and can't find the grave.


2. SOS left...
1 March 2007, Thursday 9:20 am :: http://sos.blog-city.com/

Klaus,

This is a fabulous point! Well recommended and terse. I do like terse.

When I wrote this entry, my thoughts were more aligned with the capabilities of BASH Terminal Prompt Customization.

Thusly, showing the \$(/Users/sparc/bin/TBytes.sh) was to identify the capabilities of using a subshell request to a script file.

All in all, yes, your solution is cleaner.

Thank you,

Joseph


3. Fritz left...
27 June 2008, Friday 10:27 am

Awesome. Thanks for the tutorial.


4. SOS left...
2 July 2008, Wednesday 8:01 pm :: http://sos.blog-city.com/

Glad it helped!