Submitted by YoussefAssad on Thu, 27/05/2004 - 13:14.

I was recently converted to the wonderful concept of the multi-line $PS1. Also, being the pathetic competitive type, I read a discussion on slashdot about length of the prompt and I thought to myself, ``I can do better (translation: worse)''.

So, I spent last night mucking about with color codes and arcane /proc entries and came up with a prompt so bloated that it wouldn't look out of place in Microsoft Windows XP. Features:

  • 2 lines
  • Full path of CWD
  • name of user, colorised (green if normal user, red if root)
  • time/date
  • one field alternating between the hostname in green or the text ``I am DIRTY!'' in red depending on whether the kernel has been tainted or not.
  • One viral entry in the end which does not get printed but which echoes ``God wants you to visit eglug.org'' to ~/.bashrc (the idea being to trick unsuspecting users into using this prompt and generating free advertising in the most unethical way I can currently think of)

Planned Features:

  • have code embedded in $PS1 which scans for open proxies in Catalunia and uses them to spoof e-mail to ielug requesting additional shipments of nokia phones
  • Random insults in Belgian
  • patching bash such that every command executed re-executes embedded commands within $PS1 (processor overhead? What processor overhead?)

I will post my PS1 here sometime today. It really is atrocious.


more ideas

Alaa's picture
  • make it underlined when you're logged in over ssh
  • make it show return value of latest command (very useful)
  • color code the PWD to indicate current permissions; I use 3 colors to cover write permission:
    • red for no write permission
    • cyan for write permission over a directory owned by another user
    • blue for write permission over a directory you own)
  • there is a PWD mode that collapses $HOME to ~

you can embed ansi codes to make your bash prompt write in multiple areas of the terminal, useful for making a clock on the upper corners, a fortune in a randome place or XML compliant bash sessions.

cheers, Alaa


http://www.manalaa.net

very interesting can you po

ramez.hanna's picture

very interesting can you point to a tutorial to help me understand what you are saying? and how can i do such things


the best things in life are free --- so as myself

Sure

YoussefAssad's picture

The best place to begin is http://www-106.ibm.com/developerworks/library/l-tip-prompt/

Then when you want the full thing, http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/

-- Linux Egypt Lice Resident

How about an ASCII art presen

MSameer's picture

How about an ASCII art presentation of GOATSE ??

-- Mohammed Sameer
Katoob Main developer
PekSysTray - GtkFlame

Sure!

YoussefAssad's picture
man asciiview

-- Linux Egypt Lice Resident

$ man asciiview No manual

MSameer's picture

$ man asciiview

No manual entry for asciiview

-- Mohammed Sameer
Katoob Main developer
PekSysTray - GtkFlame

Hi, I would give you some

Hi, I would give you some tips on personalizing your bash prompt. I’ve been doing this for a long, long time and I find it makes using your terminal more simple and a bit more fun.

Let’s create a yellow prompt that says URHERE:. To do this do this we will be using some different characters (and combinations therein) not used in a standard prompt. All of the below will be written within your ~/.bashrc file.

The command to get this new, unique prompt looks like:

PS1=’\\033[1;33m\URHERE: \w \\033[0m\

What does this mean? Let’s tear it apart and find out. The first sequence, `\033[1;33m\ does the following: ‘ - begin the string \[ - begin a string of non-printing characters \ - escape character preserving the literal value of the next character(s) 033 - ascii code for the escape key [ - used to separate the sequences 1;33m - defines the color yellow \w - adds the full path to the current working directory \] - ends the string of non-printing characters

The next section, URHERE:, prints our message URHERE followed by the : symbol and a space for clarity. The final section, \033[0m\’, ends our prompt with the following: \] - begin a string of non-printing characters \ - escape character preserving the literal value of the next character(s) 033 - ascii code for the escape key [ - used to separate the sequences 0m - ends the color definition \] - ends the string of non-printing characters

And there you have it. Of course you can customize this even further by changing colors or (of course) printed messages. To change the colors you will use the following strings: 1;37m White 37m Light Gray 1;30m Gray 30m Black 31m Red 1;31m Light Red 32m Green 1;32m Light Green 33m Brown 1;33m Yellow 34m Blue 1;34m Light Blue 35m Purple 1;35m Pink 36m Cyan 1;36m Light Cyan

Caballos

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.