Djihed Afifi

The bash clown prompt

8th September 2006 - 9258 Reads

My favourite UNIX shell is bash, or the Bourne Again Shell. Its syntax is neat and clean, I find it cleaner than most other shells, and it is available on most UNIX variants. its customisability is also very good. I’ve customised the default prompt to a colourful joyful and informative message. I call it the clown prompt. Here is a screenshot of how it looks like in putty, note that I have slightly changed the blue colour on putty to make it more readable.

Clown Prompt on Putty

To make it the default prompt, copy these lines to the end of your ~/.bashrc file. If there is not one, create it.

# Term settings
TTYTEMPNAME=$(tty)
CHOMPED=${TTYTEMPNAME:5}
PS1="[33[1;33m][[33[1;32m]t[33[1;33m]]
[33[1;33m][[33[1;31m]u[33[1;33m]:
[33[1;31m]h[33[1;33m]]
[33[1;33m][[33[1;36m]$CHOMPED
[33[1;33m]:[33[1;36m]#[33[1;33m]]
[33[1;33m][[33[1;35m]w[33[1;33m]]
[33[1;34m]#[33[0m] "

The first two lines grab the name of the current tty, line 3 prints the time, lines 4,5 print the username and the name of the machine, lines 6,7 prints the name of the tty along with the command number, line 8 prints the current working directory. I find all of this information valuable offhand sometimes. To apply changes, source your ~/.bashrc file by issuing: source ~/.bashrc

For peace of mind, insert this line into your ~/.bashrc file, after the previous code. It solves a problem where long lines would wrap to the same current line.

shopt -s checkwinsize

3 Responses to “The bash clown prompt”

  1. sohaib afifi Says:

    # Term settings
    TTYTEMPNAME=$(tty)
    CHOMPED=${TTYTEMPNAME:5}
    PS1=”\[33[1;33m\][\[33[1;32m\]\t\[33[1;33m\]]\
    \[33[1;33m\][\[33[1;31m\]\u\[33[1;33m\]@\ #

  2. sohaib afifi Says:

    What mean the third field [pts/?]

  3. safiyyah Says:

    I installed ubuntu hardy and downloaded minbar from the synaptic package manager. The problem is the adhan doesnt work. It has a sign next it which is an orange triangle with an exclamation mark in the middle. I have tested the files and they do work and are in the correct format (.ogg) what to do? I also e-mailed this query.

    BTW congratulation on being on the synaptic package manager list.

    Also I did try to download the version on the site, but it won’t install it says, “Error, wrong architecture i386″ could it be that minbar is currently not compatible with ubuntu hardy heron?

    jazakallahu khairun.

    Safiyyah

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>