- 论坛徽章:
- 0
|
如何定制提示符
Changing Your Command Prompt
The syntax you use to change your command prompt depends on what shell you are
using.
Bourne, Bourne Again, Korn, and Z Shells
In the Bourne, Bourne Again, Korn, and Z shells, use the PS1 command to redefine
your command prompt. The following are three examples:
To set the prompt to a colon (:), followed by a space, type the following command.
PS1=": "
To create a prompt that consists of your machine name, followed by a colon and a
space, type the following command.
PS1="‘hostname‘: "
To set the prompt to your machine name, followed by your login name in braces
{}, a colon, and a space, type the following command
PS1="‘hostname‘{‘logname‘}: "
Type any of the previous examples to change your current command prompt. This
change applies until you change your command prompt again or log out.
If you want to make your changes more permanent, add one of the previous examples
(or a prompt of your own creation) to your user profile file. If you follow this
guideline, the prompt you specify appears each time you log in in or start a new shell.
C and TC Shells
For the C and TC shells, you personalize your command prompt with the set
prompt command. The following are three examples:
To set the prompt to a percent sign followed by a space, type the following
command.
example% set prompt="% "
To create a prompt that consists of your machine name, followed by the history
number of the command (hostname1, hostname2, hostname3, and so on), followed by
a colon, type the following command.
example% set prompt="‘hostname‘\!: "
To set the prompt to your machine name, followed by your login name in braces, a
colon, and a space, type the following command.
example% set prompt="‘hostname‘{‘logname‘}: "
Type any of the previous examples to change your current command prompt. This
change applies until you change your command prompt again or log out.
If you want to make your changes more permanent, add one of the previous examples
(or a prompt of your own creation) to your user profile file. If you follow this
procedure, the prompt you specify appears each time you log in or start a new shell. |
|