Ubuntu how to modify the command prompt PS1

  

Ubuntu sometimes need to modify the command prompt PS1 when using the command, but many people do not know how to modify PS1, the following small series will introduce you how Ubuntu modify the command prompt PS1 Let's learn together.

command is not convenient nor intuitive multi-line input, in order to modify the command prompt. Modify PS1 in the ~/.bashrc file.

PS1 is the main prompt setting, generally found in ubuntu:

${debian_chroot:+($debian_chroot)}/u@/h:/w/$

The specific prompt, according to the meaning of the classification is as follows:

Main information:

/u Current login user name

/h Current computer name (such as ubuntu)

/H The current domain name of the computer, such as (ubuntu.ubuntu.com)

/w The full path to the current directory. The home directory will be replaced by ~

/W Use the basename to get the working directory name, so only the last directory will be listed

/$ The general user is $, and the root user is "

Time display

/t Current time (24-hour system, HH:MM:SS stands for hour:minute:second)

/T Current time (12-hour system)

/@ Current time (AM/PM display)

/d Current date

Shell information:

/v Bash version

/V Bash release version number

/S Shell name

/! Bash command history number

/j job number

/l Shell terminal name

I am directly omitting the user name and host, modify the 59th line of the 59th line

-------------------------------------------- ----------------

56 if [ “$color_prompt” = yes ]; then

57 PS1=‘${debian_chroot: +($debian_chroot)}/[/033[01;32m/]/u@/h/[/033[00m/]:/[/033[01;34m/]/w/[/033[00m/] /$ ’

58 else

59 #PS1=‘${debian_chroot:+($debian_chroot)}/u@/h:/w/$ ’

60 PS1=‘${debian_chroot:+($debian_chroot)}[/w]/$ ’

61 fi

----------- -------------------------------------------------< Br>

To make the change take effect immediately source ~/.bashrc

After the completion, the command prompt becomes: [~]$

The above is Ubuntu modify the command prompt PS1 The method is introduced, after modifying the command prompt PS1, the system The execution of the command will be much more convenient and I hope to help you.

Copyright © Windows knowledge All Rights Reserved