PS1="$BLUE[$CYAN\u$BLUE@$CYAN\h$WHITE-bash \v:$GREEN\w$BLUE]$WHITE \$ "

A bash prompt which shows the bash-version

The colors are defined as variables. e.g. RED="\[\033[01;31m\]" BLUE="\[\033[01;34m\]"
Sample Output
[p17@debian-bash 3.2:~] $

-3
By: P17
2009-05-06 08:01:06

These Might Interest You

  • I put that line in my .bash_profile (OS X) and .bashrc (Linux). Here is a summary of what the \char means: n=new line, u=user name, h=host, !=history number, w=current work directory The \[\e[32m\] sequence set the text to bright green and \[\e[0m\] returns to normal color. For more information on what you can set in your bash prompt, google 'bash prompt'


    7
    export PS1='\n[\u@\h \! \w]\n\[\e[32m\]$ \[\e[0m\]'
    haivu · 2009-03-09 15:34:22 0
  • If your last command was a dud, your bash prompt will be angry at you. Otherwise it's happy. Soon you will crave its constant approval and your linux skills will improve simply to avoid low self-esteem. Show Sample Output


    18
    PS1="\`if [ \$? = 0 ]; then echo \e[33\;40m\\\^\\\_\\\^\e[0m; else echo \e[36\;40m\\\-\e[0m\\\_\e[36\;40m\\\-\e[0m; fi\` \u \w:\h)"
    digitalsushi · 2009-06-30 14:29:55 8
  • Test'd & work'd fine on: HP-UX, SUSE, with bash # "Work'd" 's are wellcome! APu Show Sample Output


    0
    $ echo -e '\n## [hu_HU]Aktualis ido/datum a prompt-ba (PS1)\n# TraceBack: http://goo.gl/MlkcQ\nPS1="@\$(date +%H:%M:%S) $PS1"\n' >>~/.bashrc
    APuHun · 2012-01-20 17:17:12 0
  • Was playing with the shell. It struck to me, just by rearranging the parameters, i was able to remember what they did and in a cool way. Enter the 'hitlar' mode. bash-3.2$ ls -hitlar Shows all items with inodes, in list view, human readable size, sorted by modification time in reverse, bash-3.2$ ls -Fhitlar Shows the same with classification info. Add the hitlar mode alias to your .bashrc. bash-3.2$ echo "alias hitlar='ls -Fhitlar'" >> ~/.bashrc bash-3.2$ hitlar bash-3.2$ hitlar filename Show Sample Output


    1
    ls -Fhitlar
    ringzero · 2011-07-11 10:29:34 0
  • I use this command (PS1) to show a list bash prompt's special characters. I tested it against A flavor of Red Hat Linux and Mac OS X Show Sample Output


    3
    alias PS1="man bash | sed -n '/ASCII bell/,/end a sequence/p'"
    haivu · 2010-01-15 23:39:28 0
  • This will cause bash to fix a garbled terminal before the prompt is printed. For example, if you cat a file with nonprintable character sequences, the terminal sometimes ends up in a mode where it only prints line drawing characters. This sequence will return the terminal to the standard character set after every command.


    5
    export PS1="\[\017\033[m\033[?9l\033[?1000l\]$PS1"
    cout · 2010-07-15 19:18:05 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: