In a UNIX shell terminal, a prompt indicates the shell is ready for a command. An example:

$

PS1 is the environment variable that determines what the prompt is.  Change it to change the prompt.

For example: PS1=${PWD}> ‘ will set the prompt to display “current_directory> “.  Pay attention to the single quotes.  Using double quotes may have a different effect.

To keep your new prompt each time you log in, set PS1 in your .profile file in your home directory.

Play around.  Different shells require different symbols.  Here are some more examples.

In bash, I use: PS1=’\[\e]0;\w\a\]\n\[\e[32m\]\u@\h\[\e[0m\]\n\$ ‘

In ksh, I use: PS1=’${HOSTNAME?}:${PWD?}’`echo “\n> “‘

Tell me what you are using.



⊕ Related Posts

  • UNIX command for getting the latest version of a file


  • ⊕ Article Tags → | | | | | |

    One Response to “Personalize Your Unix Shell Prompt”

    1. Tim on July 26th, 2008 1:48 pm

      maybe it’s just the webpage, but the you are mixing single quotes and backquotes?
      ’${PWD}> ‘ ?
      ’\[\e]0;\w\a\]\n\[\e[32m\]\u@\h\[\e[0m\]\n\$ ‘?
      it would be helpful to make the distinction there…

    Leave a Reply