Changing Your bash Prompt

Depending on your Unix system, by default you might see as your prompt just a dollar sign ($), or perhaps a dollar sign and date, or other information as outlined in the Setting Your bash Prompt Promptly sidebar. You can set your prompt to include information that’s handy for you.

Code Listing 8.13. Use grep to search your configuration files for a prompt statement.
[ejr@hobbes ejr]$ grep PS1 ~/.bash*
→ ~/.bashrc /etc/bashrc
/home/ejr/.bashrc:PS1="\u \d $ "
/etc/bashrc:PS1="[\u@\h \W]$ "
[ejr@hobbes ejr]$

You actually have multiple prompts in bash:

  • The main prompt that you usually think of as the shell prompt. This prompt is called PS1.

  • A secondary prompt that you see when the system requires additional information ...

Get Unix Third Edition: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.