Complicated Prompt

The BashShell? provides zillions of ways to customize your prompt.

ChrisGarrod uses this prompt -- the prompt is shown both before and after the code that creates it:

 # 00:55:43 garrod@humu 1.74 $ cd ~ && grep ' 'PS .profile
 # yyp!!grep PS ~/.profile
 # PS is the prompt string, and can be customized a zillion ways
  PS1="\n"# PS1 is the most commonly seen prompt is PS1 see man bash
  PS1="$PS1#"# Make accidentally pasted lines comments
  PS1="$PS1$tickenv"# w/TicketNo?
  PS1="$PS1 \t" # the current time
  PS1="$PS1 \u" # the username
  PS1="$PS1@"# the at sign (we're building an email address here)
  PS1="$PS1\h"  # the host name
  PS1="$PS1 `/bin/basename $tty  2>/dev/null||/usr/bin/basename $tty `" 
  PS1="$PS1."# separate tty from command number
  PS1="$PS1\#"  # command line number in history
  PS1="$PS1 \\$"# This is a dollar sign for normal use or a # when superusered
  PS1="$PS1 cd" # make it paste cleaner
  PS1="$PS1 \w" # the working directory - bracketed by space for cut/paste
  PS1="$PS1 &&" # make it paste cleaner across multiple windows and hosts
  PS1="$PS1 "# make it paste cleaner
  PS2=""# wait to close quotes or compound statement (paste it!)
  PS3="Pick a number:"# try: select name in *;do echo $name;done
  alias PS="grep PS ~/$DotFile?"
  export PS1 PS2 PS3

# 00:56:03 garrod@humu 1.75 $ cd ~ &&

My favorite features are that inadvertant pastings of screen scrapes make prompting lines comments. The string in PS2 is actually a tab, so the whole continued command can be pasted elsewhere for future use. And having the cd to the current working directory followed by && (if it worked do the rest) and then the current command I have typed. There's also a blank line separating the output of the previous command from the prompt

PS3 is something I rarely use, so it's comment has a paster for me to try

The final result of the above code looks like this for my PS1, the primary prompt string

 PS1=\n# \t \u@\h 1.\# \$ cd \w &&
Years later, my prompt has evolved. Today it looks like this:
 # 20130415.232138 garrod@MinnieTheMoocher ttys000.1 $ cd ~ && echo $PS1
 \n# \D{%Y%m%d.%H%M%S} \u@\h ttys000.\# \$ cd \w &&

# 20130415.232155 garrod@MinnieTheMoocher ttys000.2 $ cd ~ &&
I use multiple Terminal windows on my Mac, so it helps to know which one I'm looking at just by the prompt. The first floating point number is a DateStamp.TimeStamp

That's my prompt. What's yours? -- ChrisGarrod


"Freeware" sometimes tries to trick people into installing crapware with prompts that resemble:

  Do you not want to not install the whizShop tool-bar? [Yes] [No]


EditText of this page (last edited April 16, 2013) or FindPage with title or text search