Take command of your BASH prompt
Wednesday, September 23, 2009
[Joshua] has put together a list of BASH prompt customizations. The command prompt is used in a command-line interface to show that the system is ready for the next command. Often times this is nothing more than a user name, host name, and working directory:
mike@krusty:~$
[Joshua's] customization examples can be used to color code the information in your prompt, change what information is displayed, and make the prompt respond differently when an invalid command is typed. A BASH prompt reference is helpful in deciphering what each of these commands do. The easiest simplification is to understand that non-printing characters (such as color codes) are surrounded in escaped square brackets. For example, line 1 is the sequence for Red, line 2 is the sequence for Dark Grey, and line 3 sets a simple prompt to display in Red and all text after that to be in Dark Grey:
1.
\[\e[0;31m\]
2.
\[\e[1;33m\]
3.
PS1=
"\[\e[0;31m\]\u@\h:\w\$ \[\e[1;30m\]"
0 komentar:
Post a Comment