, in 24-hour format, HH: MM o \ u: current user account name; o \ v: BASH version information; o \ w: complete working directory name. In the home directory ~ Replace; o \ W: get the working directory name using basename, so only the last directory name is listed. O \ #: commands issued. O \ $: the prompt character. if it is root, the prompt character is #; otherwise, it is $. Under Fedora 12, the content of PS1 is:
The example in the Bird's brother
After you successfully log on to a text interface, in most cases,
You will see a flickering square or bottom line on the screen (depending on different versions ),
We call it a * cursor * (cursor ).
The cursor is used to tell you where the button you entered from the keyboard is inserted,
Each input one-click cursor moves a grid to the right. If too many entries are input consecutively, the cursor is automatically input in the next row.
If you have just completed the login and have not entered a
The color code is basically clipped between "\ e [" and "m": \ e [32; 1 m
You can use \ e [0 m to disable color output. In particular, when B is set to 1, the highlighted and bold text is displayed.
Common color codes:
Foreground background color
--------------- 30 40 black 31 41 red 32 42 green 33 43 yellow 34 44 blue 35 45 purple 36 46 cyan 37 47 white
Code meaning
---------------- 0 OFF1 highlighted 4 underline5 flashing 7 reversed white display 8 invisible
Change the color of the prompt in
[Email protected] ~]# echo $PS 1 # View the main prompt ~]# echo $PS 2 # View from the prompt ~]# export ps1= ' [\[email protected]\h \w]\$ ' # Set the main prompt (temporary), If you want to permanently take effect, you should write ~/.BASHRC\u # user name\h # host name\w # Current working directory\ t # time (HH:MM:SS)\$ # If the root user displays ' # ' otherwise displays ' $ '
By default, Ubuntu kernel outputs the complete path. When the path name is long, the prompt method is unfriendly. Modify the settings of the PS1 variable by following these steps to allow the terminal to output the relative path. Similar to the Red Hat system. Change idea: Change w to W to show absolute path, and add [] brackets. First modify the/etc/bash. bashrc file www.linuxidc.com @ linuxidc-laptop :~ $ Sudovim/etc/bash. bashrc modify the followin
# PS1 = 'custom content' pay attention to the single quotation mark examples on both sides: PS1 = '(/u @/H/D/T)/$ 'your PS1: the user's usual prompt. PS2: the first line is not complete. Wait for the prompt entered in the second line. Linux system prompts are defined by the system variable ps1. The default format is [u
: hh:mm:ss\t: Display time is 12 hours format \a: Display time is 24 hours format: hh:mm\u: The current user's account name \v:bash version information \w: The full working directory name. Home directory will replace \w: with the basename to get the working directory name, so only the last directory \#: The first command issued \$: prompt character, if it is root, the prompt is: #, ordinary users are: $
Of course, in order to better identify, we can also add some color settings, this will not re
Linux PS1 prompt definition PS1: Is the user's usual prompt.PS2: The first line is not finished, wait for the second line to enter the prompt.The Linux system prompt is defined with the system variable PS1. The general system default form is: [username@host working directory]$.Use echo $PS 1 to get the PS1 value, i.e.
time is 24-hour format, such as: HH:MM:SS
\ t: Display time is 12-hour format
\a: Display time is 24-hour format: hh:mm
\u: Current user's account name
\v:bash version information
\w: Full working directory name. Home directory will replace
\w: Use basename to get the working directory name, so only the last directory
\#: The first few commands
\$: Prompt character, if root, the prompt is: #, the normal user is: $
Of course, in order to better identify, we can add some color settin
default prompt is: [Root@linux ~]#.To change the input at the shell prompt:The code is as follows:
[root@web1177 ~]# ps1= ' [\u@\h \w\#]\$ ']
This will let you know that you are entering the first few commands.
Below we will discuss in the shell variable assignment, first look at the bird book variable assignment:1. Variables and variable contents
Linux Terminal command line prompt art-PS1 advanced words not to mention, first glance at my command line prompt (a little big): the command line in the figure explains: calendar [calendar date/lunar date and time] calendar [number of directories under the current directory + number of items below the current directory] [current absolute directory] calendar [user name @ host name-number of items... linux Terminal command line prompt art-
Default:
In/etc/bashrc
PS1 = "[\ [email protected] \ H \ W] \ $"
Description:
\: An ASCII Bell character (07)
\ D: The date in "weekday month date" format (e.g., "Tue May 26 ")
\ D {format}: The format is passed to strftime (3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
\ E: An ASCII escape character (033)
\ H: The hostname up t
First, the experimental environment:installed a Red Hat Enterprise Linux 6.0 can run the system and is a successful verification system. There is another unprivileged user student, password student account exists. Second, the experimental requirements:1 , using alias Create aliases2 , using PS1 Modify Bash the prompt3 , write a simple Shell Small ProgramThird, the experimental steps:Create aliases C:[[Email
Take bash shell as an ExampleIn general, the default. bashrc should be:~ /. BashrcExport PS1 = '\ U @ \ H: \ W \ $'The above means: user @ host: Current directory $Escape SequenceIf you use a colored prompt to increase personalization, you need to use escape sequences. The escape sequence is a control command that allows shell to execute a special step. Generally
2016.1.11 today learned to change the color of PS1, how to add PS1 variable to find a file (. bash_profile), or BASHRCExport ps1= "\[\e[32;1m\]test $PWD > \[\e[0m\]"#显示绿色, where test is an additional addition to the content to be displayedExport ps1= "\[\e[35;1m\]test $PWD > \[\e[0m\]#显示红色 have a reference blog http://
Change the color of the PS1 variable.
2016.1.11 today I learned how to change the color of PS1. How to add the PS1 variable to find the file (. bash_profile) or bashrcExport PS1 = "\ [\ e [32; 1m \] Test $ PWD> \ [\ e [0m \]"# Display green, where Test adds additional content to be displayedExport
Operating Environment:
System: Mac 10.12
Editor: Vim
One, no brain configuration:1. Open the Midrange input:VI ~/.bash_profile2. Open and edit the. bash_profile file:Press keyboard "I" to enter edit modeCopy the following code:Export clicolor=1export PS1="Press esc--"W" and press "Q"--"restart terminal--" complete!Second, advanced operation:Escape characters:The above example uses a backslash-escaped sequence of characters to notify
Bash inside the variable PS1 is the user's usual prompt, the system defaults to [[email protected] working directory]$. For more information about PS1, see: http://www.cnblogs.com/starspace/archive/2009/ 02/21/1395382.htmlIn the article, it is introduced that the PS1 modification is required to be written to the ~/.bash_profile in the restart, but this is for the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.