What Your Prompt Says About You

04:14 reading time

When I was first introduced to Unix systems, I was very happy to just type away not caring much about the interface. I thought in a very classic 13 year old, naive manner: It’s just the command line, what’s there to change?! I was content with the bare minimum shell and prompt. I didn’t have any knowledge that I could change anything, nor did I have any experience as to why I would want to change it. It’s the command line after all.

In the beginning, and my recollection is hazy, it probably looked something like this:

a super basic PS1

Over time, after logging into different systems and seeing different shells and prompts, I came to the realization that I could change the interface and that I had actual reasons to change it. But really the primary reason to change it was that I could change it!

I started changing not just my default shell but my default PS1. But little stuff. Add a \u here, maybe a \W and so on and so forth. I never thought much about it, it was very fickle and it never really felt important or critical to my day-to-day work. About 12 years ago I settled on on a PS1 like this and I haven’t changed it since (kind of).

my ps1

I like my prompt. In fact, I like my prompt so much that I think everyone else’s prompts suck. And I bet you think your prompt is the best and that mine sucks. Totally cool and totally understood - it’s a programmer thing, I understand.

I like my prompt. It tells me who I am. It tells me what host I am on. It tells me where I am, on the host. And then there are the delimiters. I have been using two colons – :: – for as long as I can remember to separate my prompt from the commands that can be entered.

There are some rare times when I login to a machine and am immediately slapped in the face by an awful prompt.

a PS1 with no PS1 hulk angry

Here’s the PS1 output:

inside# echo $PS1
PS1: Undefined variable.
inside# echo $0

Ah, no bash. So let’s see it in the bash shell.

a PS1 hulk still angry

Even worse when it’s in bash, right? Here’s the PS1 output:

bash-2.05b# echo $PS1; echo $0

This prompt is really a slap in my face. It’s a jarring change from my normal prompt and it activated equal bits of crotchety old man and “who the hell set this up” outrage. Fairly typical response. But before going into “get off of my lawn” outrage, I started wondering what my teammate’s PS1’s looked like.

  • Michael Anderson
    • \n\u \W $(parse_git_branch):
  • Mike Broers
    • \h:\W \u\$
  • Rod Dennis
    • \u:\W $(parse_git_branch)$
  • Daniel Hinds-Bond
    • \u@\h \W $(parse_git_branch) $
  • Dan Lavin
    • \h:\W \u
  • Ian Melnick
    • \w$
  • Jason Pellerin
    • \w $(parse_git_branch)$
  • Kris Schultz
    • \u:\w $(parse_git_branch)$
  • Marty Walsh
    • $(ruby_version) \h:\w $(parse_git_branch)
  • Nat Williams
    • \h \w %

A little pattern emerges with the following prompt options:

  • 7 are using some kind of git context.
  • 6 are using the \u option to show username.
  • 5 are using the \h option to show the hostname.
  • 4 are using the \W option to show the basename of the current working directory.
  • 3 are using the \w option to show the current working directory.

I’d like to think that your prompt says something about you. I know for me, when I’m presented with a prompt that isn’t my own - I almost immediately type:

<some shell that isn't mine> PS1="[\u@\h] \W :: "

You are your prompt. What does your prompt say about you?