Linux Command Prompt PS1 settings-Linux general technology-Linux programming and kernel information, the following is a detailed description. 1. Current prompt:
Echo $ PS1
2. Set the prompt:
Set it in the. bash_profile file under the root directory of the user (this file does not exist, it is created), for example:
PS1 = "[\ u @ \ W] \ $"
Export
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 protected]~]$ alias c= ' Clear ' [[email pro
Linux host name color settings, ps1 settings, but linux has a color RedHat font and background color change method: Command: PS1 = "[\ e [32; 1 m \ u @ \ h \ W] \ $ "or export PS1 =" [\ e [32; 1 m \ u @ \ h \ W] \ $ "for the differences between the two, please refer to the Environment Variable related information explanation: \ e [32; 1 m: this is the escape char
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
By default, the Ubuntu terminal will output the full path, the path name is very long, the hint is very unfriendly, the following steps to modify the settings of the PS1 variable, you can let the terminal output relative path. Similar to the style of the Red Hat system. Modify the idea: Change W to W to display absolute paths, and add [] brackets.By default, the Ubuntu terminal will output the full path, the path name is very long, the hint is very un
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 PS1 in LinuxChatting with a friend, he said he had such a confusion when using Ubuntu: using the cd command in bash, after entering some deep directories, or after directories with very long names, the bash command prompt is so long that every command will wrap
Hadoop-mapred @ hdp32:/etc/opt/directorynameisfuckingsolong/my/name/is/spazzzz $This is similar to the above situation... this is the problem with the bash command prompt variable
Many people in the use of Linux, the prompt is not too much attention, can use a good prompt can be more intuitive to see, for their own judgmentLinux has PS1 PS2 PS3 PS4 Four class prompt, these four variables are environment variables, as to what environment variables in the system, you can use the command "env" to viewPS1 Command PromptPS1 has those configuration, or PS1, that can be configured with a co
If you don't want to talk about it, first glance at my command line prompt (a little big ):
The command line in the figure is as follows:Calendar [date of the Gregorian calendar/date of the lunar calendar]Else [number of directories under the current directory + number of items below the current directory] [current absolute Directory]Users [username @ host name-the number of terminals required _ hosts]
Related configuration files
Global configuration file:/etc/bash. bashrc or/ect/bashrc
Single-
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, escape sequences start with ESC (which is also the reason for its naming ). ^ [. This re
[Email protected]:~$ vim. BASHRC ps1= ' ${debian_chroot:+ ($debian _chroot)}\[email protected]\033[1;33mhttp:// 990487026.blog.51cto.com\e[m\w\$ 'Save, create a new window:Look at the effect:650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/83/B8/wKiom1d7OeTDs4mHAAAV8u1xAgI702.png "title=" 1467693446.png "alt=" Wkiom1d7oetds4mhaaav8u1xagi702.png "/>This article is from the "Soul Bucket" blog, please be sure to keep this source http://99048702
Prompt "Unable to load file PS1 when running PowerShell directly because scripting is forbidden in this system." For more information, see "Get-help about_signing".Mainly because there is no permission to execute the script.Run Get-help about_signing tips to understand execution policy inputGet-executionpolicyShow RestrictedThe execution of any script is not allowed.by commandGet-help Set-executionpolicy has the following execution strategy:Then modif
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 meaning of the prompt in the PS1 variable:\d: Represents the date, in the format weekday month date, for example: Wed Dec 12\h: Full host name. For example: hostname is debian.linux\h: Take the first name of the host only, as in the example above, then the debian,.linux is omitted \ t: Display time in 24-hour format, such as: hh:mm:ss\t: Display time 12 hours format \a : Display time is 24 hours format: hh:mm\u: The current user's account name suc
characters
Therefore, you can specify your preferred command prompt format based on these settings:
PS1 = "/u @/h:/W/$"However, the prompt displayed after this setting has no color. If you want to add a color setting, you can do this:
PS1 = "/E [1; 32 m/u/E [m/E [1; 33m @/E [m/E [1; 35 m/h/E [M: /W/$"At this point, the display in the terminal should be a color prompt, where/E [1; xxm and/E [m is the part t
PS1 scripts are all executed and can be executed directly through Windows PowerShell, but what if we want to execute a PS1 script on a regular basis? We can implement this requirement by: System planning task, the implementation method is shown below
Open: Computer Management, right-click: Task Scheduler, new Basic task,
650) this.width=650; "width=" 639 "height=" 271 "title=" image "style=" b
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 terminals] related configuration file global configuration fil
Linux under PS1 command prompt settingsAdded on the last line of this file: Vim/etc/profileexport ps1= ' [\[email protected]\h \w]\$ ' #这里必须用单引号.\d: Represents the date, in the format weekday month date, for example: "Mon 1" \h: Full host name. For example: My machine name is: Fc4.linux, then this name is Fc4.linux\h: Host name\ t: Display time in 24-hour format, such as: HH:MM:SS \ t: Display time in 12-ho
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.