change bash promt code example
Example 1: bash edit prompt display appearance
# syntax:
# export PS1='<Format required>'
# example:
export PS1='\[\033[1;33m\]\u@\[\e[0;36m\]\h:\[\e[1;32m\]$(pwd)\[\e[1;32m\]> \[\033[1;37m\]'
#===========================================================================================
# + ----------- + ----------------------------------------------------------- +
# | USABLE CODE | WHAT THE CODE REPRESENTS |
# + ----------- + ----------------------------------------------------------- +
# | \u | username |
# | \h | hostname |
# | \w | Full path of the current working directory (uses ~) |
# | $(pwd) | Full path of the current working directory (doesn't use ~) |
# | \[ | Begin sequence of non-printing characters |
# | \] | End sequence of non-printing characters |
# + ----------- + ----------------------------------------------------------- +
# + -------- + ------------ +
# | CODE | COLOR |
# + -------- + ------------ +
# | \e[0;30m | Black |
# | \e[1;37m | White |
# | \e[0;31m | Dark Red |
# | \e[1;31m | Light Red |
# | \e[0;32m | Dark Green |
# | \e[1;32m | Light Green |
# | \e[0;33m | Dark Yellow |
# | \e[1;33m | Light Yellow |
# | \e[0;34m | Dark Blue |
# | \e[1;34m | Light Blue |
# | \e[0;35m | Dark Pink |
# | \e[1;35m | Light Pink |
# | \e[0;36m | Dark Cyan |
# | \e[1;36m | Light Cyan |
# | \e[0;37m | Dark Gray |
# | \e[1;30m | Light Gray |
# + -------- + ------------ +
Example 2: how to add text to promt in linux
PS1="[\u@\h (task-7.2) \W]# "
# run this in shell and the output will look like [root@localhost (task-7.2) ~]#