Bash Prompt

From NovaOrdis Knowledge Base
Revision as of 03:41, 16 July 2020 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search




Set PS1 environment variable in .bashrc. PS1 is a primary prompt variable. PS2 bash shell variable is a secondary prompt. This prompt is displayed if the shell waits for a user input.

If used in PS1 definition, the following control character are rendered to various pieces of information:

  • \w working directory
  • \u username
  • \H host name
  • \h host name up to the first "."

Re-evaluate the Prompt on Directory Change

Introduce the command to be executed with backslash dollar instead of simply dollar:


export PS1="$(some-prompt-generating-function)"


export PS1="\$(some-prompt-generating-function)"