Friday, May 2, 2014

Customize Bash prompt

Bash prompt text is defined in PS1 variable. PS1 variable is declared in .bashrc file which is in home directory. Open this file with your favorite text editor: ~/.bashrc
Find declaration of PS1 variable (maybe there are few of them) and, if you want to permanent change prompt, change this declaration to suit your needs. If you want to change prompt temporally (recommended!) until restart, type in Bash command prompt:

$ PS1="NEW PROMPT --> "
NEW PROMPT -->

If you look in default string there are some special character with some system parameters as:

  • \u username
  • \h hostname
  • \w working directory
  • ...


$ PS1="\h:\w"
linips:~


No comments:

Post a Comment