Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

What's your 'nix prompt like?

By static in Op-Ed
Wed May 02, 2001 at 12:12:29 PM EST
Tags: etc (all tags)

It bugs me that every time I install Linux, one of the first things I have to do is fix the damn shell prompt. So I'm wondering what other people do to their shell prompt.

The default prompt for bash in Linux tends to be something like "[\u@\h \W]\\$ ". For me, there are three problems with this:
  1. The current path only includes the last directory, or ~ if your home.
  2. It puts everything in [ and ] which is visually wrong.
  3. It is missing the last program's exit code, which I use just enough to want in my prompt.
My preferred prompt is usually '$PWD [$?] \u \$ '. I have to be careful editing long lines, though, as putting environment variables in instead of shell escapes can upset bash's line count. Still, a straw poll amongst some friends showed that putting $PWD in the prompt was highly popular.

I wonder if we can take this poll results to Red Hat or Debian or anyone else and get them to change their default bash prompt?


Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure


Your shell prompt is:
o Whatever it ships with. 24%
o I always put a $PWD in. 13%
o Isn't a naked # enough? 22%
o I keep changing mine, anyway. 8%
o Something entirely different. 22%
o What's a shell prompt? 2%
o What's a shell? 6%

Votes: 135
Results | Other Polls

Related Links
o a straw poll amongst some friends
o Also by static

Display: Sort:
What's your 'nix prompt like? | 97 comments (95 topical, 2 editorial, 0 hidden)
Myself (3.00 / 1) (#1)
by Miniluv on Tue May 01, 2001 at 09:57:28 PM EST

I rarely edit $PS1, as I'm a lazy bastard. All the boxes at work however have "username@pwd #_of_commands >" which really annoys the crap out of me.

My preferred is usually uname@hostname, since I ssh around a lot in the course of my day, and always knowing which machine I'm on is much more useful than which directory I'm in, cuz 'pwd' is much shorter than 'hostname' or 'uname -h'.

Applied Solipsism worked for me.

. ./fix (none / 0) (#2)
by static on Tue May 01, 2001 at 10:05:14 PM EST

I have a little shell script called fix in root's home directory of a few boxes that aren't mine but I use. All it does is change the prompt and turn vi mode on. :-)


[ Parent ]

mine (4.00 / 1) (#3)
by enterfornone on Tue May 01, 2001 at 10:13:48 PM EST

is either "\h:\w\$ " or "\u@\h:\w\$ " (depends on whether I have more than one account on a particular machine)

what's the advantage of $PWD over \w anyway?

efn 26/m/syd
Will sponsor new accounts for porn.
Where \w falls down. (2.00 / 1) (#16)
by static on Tue May 01, 2001 at 11:46:46 PM EST

It displays ~ when I'm in $HOME.


[ Parent ]

~ is home (none / 0) (#23)
by enterfornone on Wed May 02, 2001 at 12:40:18 AM EST

What's wrong with that? I would think that's an advantage.

efn 26/m/syd
Will sponsor new accounts for porn.
[ Parent ]
IMO, it's not an advantage (none / 0) (#27)
by static on Wed May 02, 2001 at 01:12:53 AM EST

It's a handy keyboard shortcut, but I think it looks wrong in the prompt. Probably because I came to a Unix shell late in my CLI experience (I used to be a 4DOS guy).


[ Parent ]

One slow day... (4.00 / 1) (#4)
by slick willie on Tue May 01, 2001 at 10:18:03 PM EST

I decided to spruce up $PS1, so I've ended up with this gargantuan colorized prompt which has "username@host cwd$ " Each with a different color. (Hey, I said it was a slow day.)

I vary the color on the hostname to indicate whether or not it is a production-type box. A green hostname means you are good to go. Red means think twice before you delete, then think twice more.

"...there is no limit to what a man can do or where he can go if he doesn't mind who gets the credit."
--Ronald Reagan, First Inaugural Address

Agreed (none / 0) (#19)
by hph on Wed May 02, 2001 at 12:22:49 AM EST

Colors are nice. I prefer a blue '\$ '. If you need more than that you probably got ADD ;-) Afterall, thats what you got pwd and whoami for. In zsh it's nice to experiment with RPROMPT (or what it's called)

[ Parent ]
gradients (none / 0) (#29)
by enterfornone on Wed May 02, 2001 at 01:36:28 AM EST

back when I was into BBS gaming and stuff, I had a gradient prompt much like people had gradient handles in LORD etc

efn 26/m/syd
Will sponsor new accounts for porn.
[ Parent ]
Mine and Colors (none / 0) (#44)
by Devil Ducky on Wed May 02, 2001 at 11:23:44 AM EST

This comment has two resons for it's existance.

My prompt:
"[\T]<\[\033[1;34m\]\u\[\033[0m\]@\[\033[1;34m\]\h\[\033[0m\]:\w>$ "
Looks like:
And the ~ will change like $PWD any other time.

The other reason I'm here. I also use colors to distinguish which machine. The host name changes color to reflect what host I'm on, and the user name changes color to basically tell me if I'm root or not.

I don't personally like a lot of colors in the prompt, in fact I don't even like a lot of characters.

Devil Ducky

Immune to the Forces of Duct Tape
Day trading at it's Funnest
[ Parent ]
mweh. (3.00 / 1) (#5)
by harb on Tue May 01, 2001 at 10:19:43 PM EST

PS1="[\u@\h]:[\w]$ " :-)


Nothing special, I suppose.


[\u@\h \w]\n\$ (4.00 / 3) (#6)
by ucblockhead on Tue May 01, 2001 at 10:33:47 PM EST

I always use a 2-line prompt. Gives me room for real commands.

I prefer \w to $PWD as that gives a shorter path when I'm in my home area. (i.e. usually)
This is k5. We're all tools - duxup

My prompt (4.00 / 1) (#7)
by Lance on Tue May 01, 2001 at 10:41:38 PM EST

PS1="\u@\h\$ "

Very simple, really. I hate having the current directory in the prompt, because it takes up valuable space if I'm in a deep directory. Much easier to type "pwd" if I need to.

Deep directories (none / 0) (#9)
by pope nihil on Tue May 01, 2001 at 10:49:31 PM EST

The if you're worried about space, try using the uppercase \W option. It just prints the base directory instead of the whole thing printed by lowercase \w.

I voted.

[ Parent ]
Yes, but (none / 0) (#12)
by Lance on Tue May 01, 2001 at 11:00:05 PM EST

Most of the time I am able to remember which directory I am in. I rarely use pwd, but can do so very quickly if I need to.

[ Parent ]
prompt (3.00 / 1) (#8)
by pope nihil on Tue May 01, 2001 at 10:45:34 PM EST

PS1='\h [\w]\$ '

Instead of using $PWD, use lowercase \w. Works well in bash.

I voted.

On the school machines... (4.83 / 6) (#10)
by Pedro Picasso on Tue May 01, 2001 at 10:52:59 PM EST

...which I rarely use, the prompt is:
Yes, Captain?

Screw your functionality; I demand respect!
-the Pedro Picasso

Cult of the Flaky Hardware
[ (sourceCode == freeSpeech) | kakkune.com ]

Backslashes? (4.00 / 1) (#11)
by SubPar on Tue May 01, 2001 at 10:53:45 PM EST

PS1='[%n@%m %/]%# '

[user@localhost /home/user]%

What's this "bash" I keep hearing about? :-)

My favorite prompt (4.00 / 1) (#13)
by fremen on Tue May 01, 2001 at 11:18:20 PM EST

I find this TCSH prompt to be very nice on my eyes:

prompt=\<%m\>%C4"% "

It looks like this when rendered:


The hostname and directory change, of course.

needs new poll option (2.00 / 3) (#14)
by rebelcool on Tue May 01, 2001 at 11:36:38 PM EST

"I dont use linux".

COG. Build your own community. Free, easy, powerful. Demo site

Dang. (none / 0) (#15)
by static on Tue May 01, 2001 at 11:44:30 PM EST

And I was going to add something like that, too. It would have been "I don't use a shell prompt", but I forgot. Sorry.


[ Parent ]

I used to have a fancy windows prompt! (none / 0) (#21)
by a life in hell on Wed May 02, 2001 at 12:25:17 AM EST

it was all colorful, and showed the current date/time/directory/etc ;)

much better than $p$g. no unix like system required ;)

[ Parent ]
command prompt, rather (none / 0) (#28)
by rebelcool on Wed May 02, 2001 at 01:27:45 AM EST

though i found $p$g (and still do) just fine for my purposes.

COG. Build your own community. Free, easy, powerful. Demo site
[ Parent ]

Don't use Linux... (none / 0) (#43)
by ucblockhead on Wed May 02, 2001 at 10:44:19 AM EST

Does that matter?

If you spend any time in the Windows shell, do yourself a favor and either look up cygwin bash (if you know bash), or 4NT (if you prefer the Windows shell). Both are miles and miles ahead of the thing that ships with Windows.

This is k5. We're all tools - duxup
[ Parent ]

heh.. (none / 0) (#48)
by rebelcool on Wed May 02, 2001 at 01:32:12 PM EST

win2000's command line is actually pretty nice. It suits my needs.

COG. Build your own community. Free, easy, powerful. Demo site
[ Parent ]

Heh... (none / 0) (#57)
by ucblockhead on Wed May 02, 2001 at 02:20:02 PM EST

You've never used a real shell, have you?

Seriously. Win2K's shell is better than Win98's, but that's not saying much. If you want to see the real power you can get in a shell, go check out 4NT, which starts with the Windows shell, and then makes it what it should have been.

Anyway, here's three shell features missing in the Windows shell that I can't personally live without:

  • Filename completion. Typing "cd \Pro<TAB>Mi<TAB>V<TAB>VC<TAB>I<TAB><ENTER>" is a lot easier than "cd \Program Files\Microsoft Visual Studio\VC98\include".
  • Aliasing. Why even type the above? Just type "goinc<ENTER>".
  • Real command line editing beyond just scrolling through the list. Things like "execute the last compile command."

There are features, but those are the ones I refuse to live without.

And that doesn't even get into the things that are still broken in the shell, like being able to do things like "cd d:\foo" when you are on the C drive.
This is k5. We're all tools - duxup
[ Parent ]

how to... (none / 0) (#63)
by Ricdude on Wed May 02, 2001 at 03:16:51 PM EST

complete filenames on tab: fire up regedit and change \HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar to 0x09

Aliasing: you can do this with batch files, just drop them all in a ~/bin/ type directory

Real command line editing: what, and ruin dos 1.0 compatibility? F3 to copy the whole line, F2-char to copy up characters up to char, ... =)

[ Parent ]

Better than nothing. (none / 0) (#70)
by ucblockhead on Wed May 02, 2001 at 04:16:21 PM EST

That's better than nothing, I suppose, but hardly as useful as a real alias command.

Didn't know about the completion character, though.
This is k5. We're all tools - duxup
[ Parent ]

bleh.. (none / 0) (#95)
by rebelcool on Fri May 04, 2001 at 01:37:12 AM EST

i use linux at work to run my servers. Hence the reason i dont like it much. Fortunately, I only have to tap into them every few days or so.

COG. Build your own community. Free, easy, powerful. Demo site
[ Parent ]

No Subject Given (none / 0) (#45)
by Devil Ducky on Wed May 02, 2001 at 11:36:51 AM EST

A couple of minor complaints about your comment, given in the spirit of K5 complainers. :)

  • linux should be Linux
  • Windows has prompts too
  • This is NOT only a "Linux Thing", the BSDites can join this conversation too.
  • This should be an editorial
  • It is NOT Americentric!
  • It's a popular subject, so if you don't agree shut up and go to that "Other Site".

    Sorry, this started as a simple comment and ended up being a politcal statement of some kind.

    Devil Ducky

    Immune to the Forces of Duct Tape
    Day trading at it's Funnest
    [ Parent ]
  • some points... (none / 0) (#50)
    by rebelcool on Wed May 02, 2001 at 01:40:48 PM EST

    "linux should be Linux"
    Bah. ill call it whatever I want. Including LateForBreakfastix. (har har)

    "Windows has prompts too"
    Yup. The article is about the *nix's.

    "This is NOT only a "Linux Thing", the BSDites can join this conversation too."
    I've yet to actually meet someone who uses BSD... it's the mysterious OS you hear alot about, but never see.... (dont bother rebuttling, i know it exists in many places)

    "It is NOT Americentric!"
    The people who bitch about americentric posts need to start posting more brit-centric, austra-centric or batshitzania-centric things, rather than showing their obvious inferiority complex regarding america. Or maybe just vote "i dont care" which is exactly why that option exists...

    "It's a popular subject, so if you don't agree shut up and go to that "Other Site"."
    Popular to people who use linux perhaps, but id have to say a great many people who read this site dont use (and perhaps..dont like..oh my) linux. Reason being: Theres alot of other things that are more interesting to talk about than linuxy things. And since there is this number of people, they are being underrepresented in the poll which was about command prompts in *nix.

    Minority rights, baby.

    COG. Build your own community. Free, easy, powerful. Demo site
    [ Parent ]

    Hi, I'm a BSD user. (none / 0) (#67)
    by yogger on Wed May 02, 2001 at 03:58:21 PM EST

    Nice to meet you.

    The is only a test .sig
    If it were a real .sig it would contain useful and/or funny information
    [ Parent ]
    yes but.. (none / 0) (#74)
    by rebelcool on Wed May 02, 2001 at 05:46:45 PM EST

    i dont *know* you. i work with a variety of OS's on a day to day basis, and i still havent met anyone using BSD, for personal or business use.

    COG. Build your own community. Free, easy, powerful. Demo site
    [ Parent ]

    I use tcsh (4.00 / 1) (#17)
    by inti on Wed May 02, 2001 at 12:14:47 AM EST

    I don't want to comment on the relative merits of tcsh vs bash. However, my shell prompt is as follows (run from .tcshrc):

    case 'xterm':
       set prompt = '%n@%m |%{\033]0;%t - %/\007%} '
       set prompt='[%n@%m %c] '

    set rprompt = '|%h'
    set prompt2 = '--> '

    So I have different prompts for xterms as opposed to console shells. Very convenient. I also like the history number on the right hand side of the screen. Easy to parse that way.

    Claim your namespace.
    Support the OpenNIC

    Clarification... (none / 0) (#20)
    by inti on Wed May 02, 2001 at 12:25:00 AM EST

    The following gibberish

    %{\033]0;%t - %/\007%}

    writes the time and current working directory into the title bar of the xterm window. Like this:

    9:27 PM - /home/inti

    Very handy, and it updates every time you get a new prompt.

    Claim your namespace.
    Support the OpenNIC

    [ Parent ]
    xterm titlebars (4.50 / 4) (#18)
    by Estanislao Martínez on Wed May 02, 2001 at 12:20:06 AM EST

    In zsh (probably works in bash, too):

    export PS1='[%m %n %~]$ '
    if [ "$TERM" = "xterm" ] || [ "$TERM" = "xterm-color" ]
    export PS1='$ '
    function precmd { print -n "\033]2;$(print -D USERNAME@$HOSTNAME:$PWD)\007" }

    What this does: if you're running on an xterm, it displays user@host:currentdir in the title bar, and the prompt is a clean '$ '. Otherwise, '[host user dir]$ '. (This one may be zsh specific, though.)

    Essentially, I like to be able to see all that stuff at all moments, and find having the whole path in the prompt cumbersome, yet preferable to nothing. Thus, the title bar of an xterm is the ideal spot.


    only zsh (4.00 / 1) (#25)
    by mike-c on Wed May 02, 2001 at 12:57:26 AM EST

    has the precmd function, but you can do the same thing in bash by replacing that line with

    PROMPT_COMMAND='echo -ne"\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

    More info at the Xterm Title HOWTO.

    -- "If things don't go your way, just keep complaining until your dreams come true." -- President Clinton to Lisa Simpson
    [ Parent ]

    Re: only zsh (none / 0) (#78)
    by DJBongHit on Wed May 02, 2001 at 06:19:24 PM EST

    has the precmd function

    tcsh does as well.


    GNU GPL: Free as in herpes.

    [ Parent ]
    You don't need a separate command. (none / 0) (#46)
    by Phil Gregory on Wed May 02, 2001 at 01:18:08 PM EST

    You don't really need to run a separate command to get a title. I just put the titlebar stuff in my prompt. I would set up your prompt thusly:

    ESC=`echo -en "\033"`
    BEL=`echo -en "\a"`
    case $TERM in
        PREFIX="[%m %n %~]"
    export PS1="$PREFIX\$ "

    For bash, I think you'd have to use \[ and \] instead of ${ and %}.

    --Phil (I haven't even proven the above code, let alone tested it.)
    355/113 -- Not the famous irrational number PI, but an incredible simulation!
    [ Parent ]
    my bash prompt (4.00 / 1) (#22)
    by Sven on Wed May 02, 2001 at 12:35:44 AM EST

    I think my preferred prompt originally came from either Slackware 3.0 or RedHat 4.2, I'm not sure which. I usually do PS1='\h:\w\\$ ', but a while back I added some colour and an xterm title, and I ended up with this monstrosity...

    function proml {
      case $TERM in
          local TITLEBAR='\[\033]0;\h:\w\007\]'
          local TITLEBAR='\[\033]0;\h:\w\007\]'
          local TITLEBAR=''

      PS1="${TITLEBAR}\[\033[1;33m\]\h:\[\033[1;36m\]\w\[\033[0m\]\\$ "


    Crazy stuff.

    harshbutfair - you know it makes sense

    out of columns, use a row (4.20 / 5) (#24)
    by ism on Wed May 02, 2001 at 12:57:16 AM EST

    I like my working directory in the prompt, but of course when directories start getting deep, the prompt starts taking up too much horizontal space. It's a kludge, but I put the prompt on a new line:

    export PS1='\[\033]0;\w\007
    \033[00;32m\]\u@\h \[\033[01;34m\w\033[0m\]
    $ '

    which comes out:

    user@host /directory

    in a color scheme that matches my .dircolors.

    What I used to do for DOS. (none / 0) (#26)
    by static on Wed May 02, 2001 at 01:08:48 AM EST

    I used to do something like that in 4DOS. It began as the current path, then a newline, then a ». Over the years, it morphed into the current path, the last error code in [ ], the current shell number, the PC's name, a newline, then a ». All in different colours, of course!


    [ Parent ]

    My prompt... (4.00 / 1) (#30)
    by fink on Wed May 02, 2001 at 01:39:46 AM EST

    ... is this ugliness below:
    \n[ \[\033[1;36m\]\t\[\033[0m\] | \[\033[1;33m\]\u@\h\[\033[0m\] ] ( \[\033[1;35m\]\w\[\033[0m\] )\n$

    I used to have all sorts of trouble remembering which machine I was on, so I did the above.

    For those who don't feel like parsing it (or using bash to parse it..), here's what it looks like:
    [ 15:46:52 | iroberts@buffy ] ( ~ )

    Of course, there's colours in it as well, which don't come up.

    That one little trick has saved my skin several times from typing su - on the wrong machine...

    Double whammy is that the ~ is replaced with the full directory, if/when I change into a different non $HOME directory.

    I even ported it to tcsh, for the one Solaris machine that I had to use, that didn't have bash. However, that's no longer a problem, so this is It.


    Slackware default.. (4.00 / 3) (#31)
    by Inoshiro on Wed May 02, 2001 at 01:51:13 AM EST

    From /etc/profile:
    # Set a default shell prompt:
    #PS1='`hostname`:`pwd`# '
    if [ "$SHELL" = "/bin/pdksh" -o "$SHELL" = "/bin/ksh" ]; then
    PS1="! $ "
    elif [ "$SHELL" = "/bin/zsh" ]; then
    PS1="%n@%m:%~%# "
    elif [ "$SHELL" = "/bin/ash" ]; then
    PS1="$ "
    PS1='\u@\h:\w\$ '
    PS2='> '

    It looks something liko this: dylang@shadowgate:~$ . I like it.

    [ イノシロ ]
    My prompt (4.00 / 1) (#32)
    by Anonymous 6522 on Wed May 02, 2001 at 03:04:20 AM EST

    PS1="\h \@ \$"

    Which looks like:

    hostname XX:XXam/pm $

    No fancy pwd stuff for me. Heck, I don't even have the username in it because I always have the same one.

    What's my prompt like? (4.50 / 6) (#34)
    by kmself on Wed May 02, 2001 at 03:49:29 AM EST

    Raindrops on roses and whiskers on kittens, bright copper kettles and warm woolen mittens, brown papper packages tied up with strings. Moonlit walks on the beach, freshly baked bread, and really strong Columbian espresso. Sunset over the Golden Gate, fog pouring through the hills, and morning mists. Backrubs, right there. Miles. Satie. Ansel Adams photography. The Pre-Raphaelites. Greco. Eliot. Dead Kennedies. Unexpected upgrades to business class. Road trips. Standing on the edge of Half Dome. The burn of a century ride. A Sierra sunrise. A contented cat.

    These are a few of its favorite things.

    Karsten M. Self
    SCO -- backgrounder on Caldera/SCO vs IBM
    Support the EFF!!
    There is no K5 cabal.

    My prompts (none / 0) (#35)
    by evvk on Wed May 02, 2001 at 05:10:47 AM EST

    (The prompts below require bash.)

    PS1='\h:\w$ ', i.e. 'hostname:pwd$ '
    and PS1='\h:\w# ' for root. No ugly redhead-default square brackets plus pwd basename for me.

    However, with \w the paths sometimes get way too long. The next prompt is quite handy in this case, without having to resort to always displaying just the basename. Unfortunately it isn't exactly very light:

    PS1='\h:`echo "\w"|sed "s/.\{4,\}\(.\{50\}\)$/\.\.\.\1/"`$ '

    Mod to Slackware prompt (none / 0) (#47)
    by Farq Q. Fenderson on Wed May 02, 2001 at 01:18:38 PM EST

    PS1='\h:\w$ ' - that's the default prompt that Slackware (7.0, at least) has, which is nice. I've only got two users that I use on my box, and one's root - so there's -no- need to put in user info.

    However, in light of this article, I've made a minor mod to my prompt, I've added '[$?] ' to the beginning of my prompt - 'cause that kind of info is really nice to have as a coder.

    farq will not be coming back
    [ Parent ]
    \h:\w$ (none / 0) (#54)
    by evvk on Wed May 02, 2001 at 02:10:22 PM EST

    I think slackware already had this prompt in the 1.2 kernel era, when I first came acquainted with *nix. I've had many prompts since then, but I always came back to this.

    [ Parent ]
    Yes (none / 0) (#90)
    by Farq Q. Fenderson on Thu May 03, 2001 at 10:31:01 AM EST

    I can confirm that.

    Come to think about it, I literally had a nightmare about redhat's default prompt about a year ago. - no joke.

    farq will not be coming back
    [ Parent ]
    *bow* (none / 0) (#82)
    by static on Wed May 02, 2001 at 07:58:41 PM EST

    I suspected many people didn't realize just how useful having the last error code in the prompt was! :-)


    [ Parent ]

    My prompt (3.00 / 1) (#36)
    by zztzed on Wed May 02, 2001 at 06:55:47 AM EST

    Looks like this:

    No, just kidding. It actually looks like this:
    [arianne:~] michael% echo $PROMPT
    [%m:%~] %n%%
    (Using zsh 3.1.9, btw, in case you're wondering. Hooray for programmable completion! zsh über alles!)

    Zsh has right-justified prompts (4.33 / 3) (#38)
    by pabw on Wed May 02, 2001 at 09:07:22 AM EST

    I have this in my .zshrc:
    export PS1='%{'$C_PROMPT'%}%B[%! %n@%m]%(#.#.$)%b%{'$C_DEFAULT'%} '
    export RPS1='%(?..%{'$C_ALERT'%}< %? > )%{'$C_DIR'%}%~%{'$C_DEFAULT'%}'

    Which yields something like this: (With some colors)
    [225 pwilson@pl]$                      < 1 > ~/docs
    The <1> at the the end is the error code from the last command; it doesn't appear if it's 0.
    Zsh hides RPS1 if the command gets too long. Having the full-but-abbreviated path always available without it ever getting in the way is nice.

    Pretty boy prompts (3.50 / 2) (#39)
    by theboz on Wed May 02, 2001 at 09:20:41 AM EST

    Awww...you put $PWD in your path? Aren't you intelligent enough to be able to remember where you are?

    Seriously though, sometimes the directories I work in are too long and if I had pwd in there it would be a pain in the ass. I've seen people that put two lines or more in their prompt and stuff but that gets in the way.

    Wanna know what my prompts look like? Well, I have $ and # depending on what system and shell I am using. I mostly use ksh and tcsh.


    Re: Pretty boy prompts (none / 0) (#52)
    by WWWWolf on Wed May 02, 2001 at 01:56:24 PM EST

    Awww...you put $PWD in your path? Aren't you intelligent enough to be able to remember where you are?
    Not at 4 in the morning...

    $ pwd
    $ cds ../tmp/crap
    bash: cds: command not found
    $ rm -rf *

    (drowsy voice) "Why it takes so long?"

    This is why my minimum prompt includes \w. =)

    -- Weyfour WWWWolf, a lupine technomancer from the cold north...

    [ Parent ]
    It's called adapting the computer to you. (none / 0) (#83)
    by static on Wed May 02, 2001 at 08:03:06 PM EST

    For example, I did a difficult FTP download the other day involving getting a whole tree of files off an FTP server onto a workstation. Since neither ftp nor ncftp could do a recursive get, I was getting files and directories pretty much one-by-one. Keeping track of where I was with pwd and lpwd was frustrating, to say the least. That's the sort of reason I like the whole path in my prompt - and that excludes the write-only ~ shortcut.


    [ Parent ]

    prompt? we dont need no stinking prompt (3.00 / 1) (#40)
    by unstable on Wed May 02, 2001 at 09:31:32 AM EST

    I have the default bash prompt that shipped... but i dont even pay attention to it.. I would be fine in a straight # or $ but why bother changing it?

    Reverend Unstable
    all praise the almighty Bob
    and be filled with slack

    Way too useful. (2.66 / 3) (#41)
    by provolt on Wed May 02, 2001 at 10:37:08 AM EST

    Everyone seems to have a prompt that is way too useful. Prompts can be so much more fun than that.

    What is your bidding my master? - $
    What would you like, your highness? - $
    What now? - $

    even less useful (none / 0) (#58)
    by mr death on Wed May 02, 2001 at 02:29:56 PM EST

    What the Fuck do you want? - $

    [ Parent ]
    Useless AND slow... (none / 0) (#79)
    by MrSmithers on Wed May 02, 2001 at 06:43:25 PM EST

    PS1=`fortune` \n\$

    [ Parent ]
    Oops! (none / 0) (#80)
    by MrSmithers on Wed May 02, 2001 at 06:44:58 PM EST

    Was supposed to be...

    PS1='`fortune` \n\$'

    [ Parent ]
    You asked... (3.50 / 2) (#42)
    by Phil Gregory on Wed May 02, 2001 at 10:41:09 AM EST

    I like a lot of information in my prompt, and I like it to look good, too. My current prompt (in zsh) looks approximately like this (from an 80-column window):

    --(Wed, 02 May 01:%)--                                              --(10:05)--

    In most of my terminal windows, however, I use ASCII shift-in and shift-out (^N and ^O) to make nicer-looking lines, complete with connections between the upper and lower lines at each end. I have terminal detection (a case statement) that decides whether to use the line drawing or straight ASCII sharacters. I also, if I'm running in an xterm, put user@host:pwd in the title bar.

    The upper line of the prompt auto-sizes to the size of my terminal and truncates the beginning of the working directory if it gets too long.

    --(Wed, 02 May 01:%)--                                              --(10:11)--

    Most of this behaviour was cribbed from the Bash Prompt HOWTO and converted to work with zsh. With zsh I also put the time on the right side of the prompt (the cursor is right after the date), mostly just because I could.

    Everything is also color coded for ease of identifying information. user@hostname is in green, pwd is in magenta, the time is in yellow, and the lines are in cyan with the '-(' and ')-' surrounding each item in blue. Root has a similar prompt, but root's lines are red with yellow trim. It's thus easy to tell at a glance whether I'm root or a normal user and, with a closer glance, wat user and machine a particular prompt is using.

    If anyone's interested in the scripts I use, I can put up a web page when I get home tonight showing how I do all of this.

    --Phil (It's a bit of work, but I have to look at my prompt every day, so it's justified work.)
    355/113 -- Not the famous irrational number PI, but an incredible simulation!
    Prompt Available Online (none / 0) (#96)
    by Phil Gregory on Mon Jul 09, 2001 at 10:13:16 AM EST

    Well, I finally got around to putting up a web page about my shell prompt, mostly in response to emails I got regarding a post on Slas^H^H^H^Hthat Other Site. Regardless, if anyone comes across my post above, they will now know where to find my prompt information.

    --Phil (Yeah, I'm replying to my own post.)
    355/113 -- Not the famous irrational number PI, but an incredible simulation!
    [ Parent ]
    New URL (none / 0) (#97)
    by Phil Gregory on Sun Dec 15, 2002 at 04:48:44 AM EST

    And I've switched domain names (hopefully for the last time). New location is at http://aperiodic.net/phil/prompt/.

    --Phil (Must remember to renew this domain on time.)
    355/113 -- Not the famous irrational number PI, but an incredible simulation!
    [ Parent ]
    My prompt (3.00 / 1) (#49)
    by WWWWolf on Wed May 02, 2001 at 01:39:49 PM EST

    export PS1='\h:\w\$'
    export PS2='>'

    This was the Slackware's Bash default prompt, much more informative than Debian's default, PS1='\$', and not as spammy as Redhat/BestLinux defaults that I've seen... =)

    Just host name and current directory. I don't want user name (I know who I am, dammit - the \$ tells already whether I'm r00t or mortal), date/time, or exit statuses. Simplicity is beautiful.

    -- Weyfour WWWWolf, a lupine technomancer from the cold north...

    Nearly the same as mine (none / 0) (#92)
    by nobody on Thu May 03, 2001 at 01:31:04 PM EST

    Tells me what I need to know, in the minimum space.

    In capitalism, man exploits man. In socialism, it's exactly the opposite.
    [ Parent ]
    I happen to like the default (3.00 / 1) (#51)
    by CrayDrygu on Wed May 02, 2001 at 01:46:35 PM EST

    I'll go through your same points as a base...

    1) It's a problem that only the last directory of the path (or ~) is shown? I like it fine that way. I usually remember where I am, and I'd rather not have big long paths in my prompt.

    2) Putting everything in [ ] helps me visually distinguish it from other output on the screen, and the command I'm typing.

    3) I rarely need the last program's exit code enough to have it in my prompt.

    Just my 2 cents.

    Fair enough. (3.00 / 1) (#84)
    by static on Wed May 02, 2001 at 08:16:38 PM EST

    I'd say they are valid reasons.

    Something I didn't feel I needed to mention initially was that most of my CLI experience was at a DOS prompt, initially COMMAND.COM but mostly 4DOS. The default prompts for both don't put the working directory in [ ] and I simply got used to that. So now, the [ ] around the lot are visual clutter to me.

    It's for much the same reason that I dislike ~ in my prompt or just the last directory. Both behaviours require me to think a tad more carefully when at a shell prompt, and why do that if I don't need to? The risk of long paths in my prompt is a better one, to me.


    [ Parent ]

    C:\$PWD> (2.50 / 2) (#53)
    by jabber on Wed May 02, 2001 at 02:05:13 PM EST

    Just for yuk-yuks..

    [TINK5C] |"Is K5 my kapusta intellectual teddy bear?"| "Yes"

    taken from slackware's default i think (3.00 / 1) (#55)
    by Justinfinity on Wed May 02, 2001 at 02:10:38 PM EST

    justin@joker:~/tmp$ echo $PS1

    i know who i am, what machine i'm on, and where i am on that machine. i use screen alot, so it's nice to know at a glance what window i'm in.

    bash --version
    GNU bash, version 2.04.0(1)-release (i386--freebsd4.2)


    if this is all a dream, please, don't wake me

    oh yeah, i forgot to mention (none / 0) (#56)
    by Justinfinity on Wed May 02, 2001 at 02:19:33 PM EST

    with screen, and two windows between two boxes sshed together, you can use that prompt to copy/paste the path right into scp for easy copying without much typing


    if this is all a dream, please, don't wake me

    [ Parent ]
    tcsh copy and paste friendly (none / 0) (#59)
    by Norom on Wed May 02, 2001 at 02:59:54 PM EST

    set prompt = ": %n@%m %c ; "

    which comes out as

    : user@host cwd ;

    Thus you can highlight an entire line in an xterm and only the command will run when you paste in another xterm.

    : Cool ; (none / 0) (#87)
    by scruffyMark on Thu May 03, 2001 at 12:42:44 AM EST

    That's really handy! It works in more than just tcsh, too (both sh and csh shells).

    I use Mac OS X, so there is even real copy-paste support... Sorry, had to throw that in.

    [ Parent ]

    in tcsh, i do... (none / 0) (#60)
    by Ricdude on Wed May 02, 2001 at 03:02:09 PM EST

    set promptchars="-#"
    set prompt="%{$WHTBLK%} %n@%m %{$REDBLK%} [%~] %{$PPLBLK%} - %h %# %{$NONE%} "

    where the $WHTBLK, $REDBLK, and $PPLBLK are color codes for white on black, red on black, purple on black.

    i tend to live in xemacs, however, instead of the command line, so it's not nearly as useful to me to clutter it up with extra info. just a reminder of who i am, where i am (machine and directory), and the command count (for history !n shortcuts) is enough for me.

    In my DOS days... (none / 0) (#61)
    by Nurgled on Wed May 02, 2001 at 03:04:03 PM EST

    All those years ago when I used DOS, I used ANSI control codes to shift the cursor to the top-left of the screen and print on a "title bar" containing my current working directory, the date and probably other information I forget now. It used the "remember position" and "restore position" codes to provide a minimal prompt (probably a greater-than sign) at the entry point.

    These days, however, I'm too lazy to bother with messing with prompts. I tend to just use whatever I'm given, unless it's bash$, in which case I'll probably set it to [user@host pwd]$ ... but other than that I'm not wholly fussed. I can generally remember my pwd and what host I'm on anyway.

    Fairly simple, at last (none / 0) (#62)
    by Rainy on Wed May 02, 2001 at 03:10:37 PM EST

    I used to have a fancy prompt (in fact, many different variations, multiline and all.. once i even tried a 3-line one), but that stuff gets distracting after a while and so now I have a rather simple one.. here's how it looks:
    Where 2 means the number of jobs in the background - I tend to have alot of aterms open and forget if I have anything in background.. Anyway, here's the source (bash):
    With nice colors, of course.. Here's the jobcount thingy from .bashrc: function jobcount { jobs|wc -l| awk '{print $1}' }

    Oh, and root prompt doesn't have job count and \w is rendered in red.
    Rainy "Collect all zero" Day

    Why just the prompt? WM setup, aliases, etc: (none / 0) (#64)
    by Rainy on Wed May 02, 2001 at 03:35:25 PM EST

    My WM of choice is WindowMaker, and it's set up with some semi-vi bindings - alt-j/k switches windows in current workspace, alt-l/h switches workspaces, alt-u maximizes/minimizes, alt-i starts an aterm, alt-f opens the main menu popup, alt-d popups list of windows. I have wmnet, wmweather and asclock on my wharfbar. I start aterm with this line: aterm -tr -trsb -sh 30 -bg black -sl 1000 -fg gray -sr -fn -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-1, which makes it transparent but shades the background so that the text (white) is perfectly legible.

    Aliases: alias jbos='jobs'
    alias v='vim'
    alias mg='mv *gz .archive/'
    alias cm='./configure; make'
    alias rip='cdparanoia -B -d /dev/hdd "1-"'
    alias ll='ls -l'
    alias ly='ls *py'
    alias la='ls -a'
    alias pd='pushd'
    alias pd2='pushd +2'
    alias mp="mpg123"
    alias e="exit"
    alias lower="perl -e 'for (@ARGV) { rename $_, lc($_) unless -e lc($_); }' *"
    alias mp3='mlame -o "-m s -b 128" -r *wav; beep3'
    alias cl='cd; clear'
    alias lc='cd; clear'
    alias beep3='beep; sleep 1; beep; sleep 1; beep'
    alias so="source ~/.bashrc"
    alias py="python"
    alias mail="mutt"
    alias todo="cat ~/.t/todo"
    alias etodo="vim ~/.t/todo"
    alias f="fc -ln -15"
    alias r='fc -s'
    alias du="du -h"
    alias df="df -h"
    alias bx="bitchx"
    alias x="startx"
    alias mcd="mount /cd; cd /cd"
    alias ucd="cd; umount /cd"
    alias ta="tar zxvf"
    alias ti="tar Ixvf"
    alias ls='ls --color'
    alias md='mkdir'
    alias lx='/usr/local/bin/lynx'
    alias chess='gnome-chess --fcp=gnuchess'
    export WWW_HOME="$HOME/.lynx-bookmarks/main.htm"
    echo; fortune; echo
    cat ~/.t/todo

    I'd post my vimrc too but I still havent gotten around to commenting it properly :/

    And last but not least - I got most of my background pictures from digitalblasphemy.com, but I don't like them much, except for a few. Does anyone know a really good place for wallpapers of high quality? For instance, on windows I used to use a second nature program for that and it had a really good collection - nature, paintings, fantasy, hundreds of them.
    Rainy "Collect all zero" Day

    you forgot a few... (none / 0) (#75)
    by StackyMcRacky on Wed May 02, 2001 at 05:47:37 PM EST

    i always need:

    alias gerp grep
    alias grpe grep
    alias Grep grep

    [ Parent ]
    Then there is (none / 0) (#77)
    by ucblockhead on Wed May 02, 2001 at 06:13:42 PM EST

    alias dir=ls
    alias copy=cp
    alias del=rm

    And my personal favorite:

    alias zap='rm -rf'
    This is k5. We're all tools - duxup
    [ Parent ]

    As well as (none / 0) (#85)
    by frozencrow on Wed May 02, 2001 at 08:32:48 PM EST

    alias kitty=cat
    alias date='echo "Not with YOU!"'
    alias zzz=sleep
    alias grope=touch
    alias suicide='killall `whoami`'

    [ Parent ]
    why? (none / 0) (#89)
    by Rainy on Thu May 03, 2001 at 06:31:03 AM EST

    copy, etc is longer than cp, mv.
    Rainy "Collect all zero" Day
    [ Parent ]
    DOS (none / 0) (#91)
    by ucblockhead on Thu May 03, 2001 at 01:14:59 PM EST

    I used to use those when I was going back and for between DOS and unix. Finger memory.

    This is k5. We're all tools - duxup
    [ Parent ]

    tcsh (none / 0) (#65)
    by jethro on Wed May 02, 2001 at 03:37:33 PM EST

    I use tcsh, and my prompt is

    set prompt="%S%n@%m%s:%/%# "

    for the non-tcsh-enabled or lazy masses, this does:

    <reverse video>username@hostname</reverse video>:current directory/

    The trailing slash turns into a hashmark if you're root.

    In the land of the blind, the one-eyed man is kinky.
    Fairly basic (none / 0) (#66)
    by shrub34 on Wed May 02, 2001 at 03:56:31 PM EST

    In BASH is use host $ or host # for root

    nothing fancy, just want to know what system I'm on and wether I'm root. I don't find difficult to type in pwd for current dir.

    It's good to see the BSD community forking and execing so many child processes.

  • Comment about editor of Daemon News not attending BSDco
  • My zsh prompt (none / 0) (#68)
    by invdaic on Wed May 02, 2001 at 03:59:51 PM EST

    PROMPT='%n@%m:%B%~%b%% ' RPROMPT='[ %t ]' Which shows: invdaic@hostname:pwd% and then has the time inside [] on the right.

    "I cannot imagine a God who rewards and punishes the objects of his creation [and] is but a reflection of human frailty." --Albert Einstein

    zsh prompt: (none / 0) (#86)
    by lahvak on Wed May 02, 2001 at 11:13:34 PM EST

    mine is similar, except it has exit code on the right, too:

    PS1="%S%m%s:%~ [%h] "
    RPS1="<%@ %(?.OK.%?)"

    I used to use screen a lot, and under screen I had

    PS1="%S%m%s (window $WINDOW):%~ [%h] "

    so I could keep track in which virtual terminal windows I was.

    [ Parent ]
    Compact, Informative zsh Prompt (none / 0) (#69)
    by rjsjr on Wed May 02, 2001 at 04:06:53 PM EST

    Here's my zsh prompt, I spent way too much time fiddling around with this a while ago. I like it since its compact, but informative. See the zsh manual for full details, but the general format is host:path (~ abbreviated) with indications for superuser ($/#, for some reason %# has problems) or non-standard account, multiple shell levels, and is bolded to make the prompt stand out from the command line (usually I map bold to same font weight, but different color).

    case $USERNAME in
    rjs | seymour | rseymour | root)
    PS1="%B%m:%~%2(L.($SHLVL).)%(#.#.$)%b "
    PS2="%Bzsh:%~%2(L.($SHLVL).)%(#.#.$)%b "
    PS4="%Bzsh+%b "
    PS1="%B%n@%m:%~%2(L.($SHLVL).)%(#.#.$)%b "
    PS2="%Bzsh:%~%2(L.($SHLVL).)%(#.#.$)%b "
    PS4="%Bzsh+%b "

    Regards, RJS

    Colored prompt (none / 0) (#71)
    by a clockwork llama on Wed May 02, 2001 at 04:35:01 PM EST

    I often use the linux console, and I can't stand the default console text. The bland white text reminds me of MS-DOS, and the blinking cursor drives me nuts. So I've made my Bash prompt bright green, with a solid dark green cursor that doesn't blink. This requires some trickery with escape sequences:

    PS1='\033[1;32m\033[?17;5;40c\w \$ '

    I've also chosen a color scheme for 'ls' with /etc/dir_colors, and selected a smaller font for console text using the framebuffer. At the end of the day, the console feels MUCH nicer to use, for me at least.

    Re: What's your 'nix prompt like? (none / 0) (#72)
    by jcs on Wed May 02, 2001 at 05:40:50 PM EST


    My prompt (none / 0) (#73)
    by DJBongHit on Wed May 02, 2001 at 05:42:39 PM EST

    I use tcsh (the one true shell! :). In my .tcshrc file, I have this line:

    set prompt="\n[%c1]%{^[[0m%}%b %{^[[32m%}%@ %n@%m>%{^[[0m%} "

    This makes my prompt look like this (BOLD translates to green on screen):

    [~] 5:49pm spong@imack>

    I've had it like that for years.


    GNU GPL: Free as in herpes.

    KISS method (none / 0) (#76)
    by puckchaser on Wed May 02, 2001 at 06:04:49 PM EST

    I prefer to keep the command line as simple as possible. I make use of the xterm (or equiv.) title bar for the extra information such as hostname, working directory. and command history info, using...

    \033]2;\h \w (\!) \007\n=>

    So my prompt is actually "=>".

    zsh prompt (none / 0) (#81)
    by tribbel on Wed May 02, 2001 at 07:49:55 PM EST

    Okay, here's mine:

    /home/cris> echo $PS1

    `Geewiz, tribbel, what does that do?' you ask? I'll tell you:

    The first bit examines the return code of the process executed before showing the prompt. If the process exited with a non-zero return code this code will be printed like "69:" (well, underlined or in an icky sort of green, actually). If it was zero nothing will be shown.

    Next up is the current working directory which will be truncated at 40 characters (after that a ... will be added).

    And then there is a '>' character which is either underlined when the user is root, or bold when the user is... well... not root.

    This concludes our lesson for today, children.

    From bashrc (none / 0) (#88)
    by QuoteMstr on Thu May 03, 2001 at 02:51:24 AM EST

    Ordinary prompt, cyan on blue, with some magic to change the xterm title.

    if [ $TERM = emacs ]; then
       alias ls='ls -F'
       PS1='[\w]\$ '
    elif [ $TERM = xterm ]; then
       alias ls='ls --color=auto -F'
       PS1="\[\033]0;\w\a\e[36m\][\[\e[44m\]\w\[\e[49m\]]\[\e[1m\]\$ \[\e[0m\]"
       alias ls='ls --color=auto -F'
       PS1="\[\e[36m\][\[\e[44m\]\w\[\e[49m\]]\[\e[1m\]\$ \[\e[0m\]"

    This has been useful (none / 0) (#93)
    by scruffyMark on Thu May 03, 2001 at 02:51:00 PM EST

    After reading some comments here, I fiddled about with my .tchsrc and came up with this:

    %B: %?%b%{\033]0;%n@%m:%c3\007%}%B %t; %b

    This makes the terminal titlebar look like:
    and the prompt:
    : 0 12:31pm;
    where the 0 is the exit status of the last command. The prompt is in bold to visually set it apart from the command, and the : and ; make the whole thing copy-paste friendly - copying the whole line only executes the command.

    The %{\033]0; and \007%}, which manipulates the title bar, seems not to work in regular csh.

    Thanks to all the posters I imitated to get that to work!

    I've run prompt topics before. (none / 0) (#94)
    by static on Thu May 03, 2001 at 07:20:54 PM EST

    Though this is the first I posted to K5. With a large enough readership, people who think they have clever prompts usually show them off. And other people get lots of neat ideas! :-)


    [ Parent ]

    What's your 'nix prompt like? | 97 comments (95 topical, 2 editorial, 0 hidden)
    Display: Sort:


    All trademarks and copyrights on this page are owned by their respective companies. The Rest © 2000 - Present Kuro5hin.org Inc.
    See our legalese page for copyright policies. Please also read our Privacy Policy.
    Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
    Need some help? Email help@kuro5hin.org.
    My heart's the long stairs.

    Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!