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:
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).
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.
Here’s the PS1 output:
inside# echo $PS1 PS1: Undefined variable. inside# echo $0 -csh
Ah, no bash. So let’s see it in the bash shell.
Even worse when it’s in bash, right? Here’s the PS1 output:
bash-2.05b# echo $PS1; echo $0 \s-\v\$ bash
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
- Rod Dennis
- Daniel Hinds-Bond
\u@\h \W $(parse_git_branch) $
- Dan Lavin
- Ian Melnick
- Jason Pellerin
- Kris Schultz
- 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
- 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?