====== Shell Prompt ====== {{template>meta:template:pageinfo#tpl |desc=Introduce the way the shell prompt is displayed and record some tips.}} ===== Change prompt ===== ==== change prompt temporarily ==== * Run export PS1='Combination of [[#Prompt Options|options]]'. \\ e.g. export PS1='\u #' ==== Change Prompt Permanently ==== * Open the ~/.bashrc with editor. * Search and change the ''PS1'' variable to ''%%'%%//Combination of [[#options]]//%%'%%''. \\ e.g. PS1='\[\033[01;34m\]\W\[\033[00m\]$' * Run source ~/.bashrc. ===== Prompt Options ===== The following options you can use for the BASH prompt are copied from [[https://phoenixnap.com/kb/change-bash-prompt-linux]]. \\ \\ ''Some of these options may not work on all versions of Linux.'' \a – A bell character \d – Date (day/month/date) \D{format} – Use this to call the system to respond with the current time \e – Escape character \h – Hostname (short) \H – Full hostname (domain name) \j – Number of jobs being managed by the shell \l – The basename of the shells terminal device \n – New line \r – Carriage return \s – The name of the shell \t – Time (hour:minute:second) \@ – Time, 12-hour AM/PM \A – Time, 24-hour, without seconds \u – Current username \v – BASH version \V – Extra information about the BASH version \w – Current working directory ($HOME is represented by ~) \W – The basename of the working directory ($HOME is represented by ~) \! – Lists this command’s number in the history \# – This command’s command number \$ – Specifies whether the user is root (#) or otherwise ($) \\– Backslash \[ – Start a sequence of non-displayed characters (useful if you want to add a command or instruction set to the prompt) \] – Close or end a sequence of non-displayed characters ====== Reference ====== * //[[https://phoenixnap.com/kb/change-bash-prompt-linux]]//