如何通过Linux bash定制shell提示符?

来源:百度知道 编辑:UC知道 时间:2024/05/22 19:19:20

你可以定制bash shell提示符以显示当前用户名和主机名、当前时间、平均负载和/或当前工作目录。要实现这一点,像下面这样改变$PS1变量:

bash> PS1='u@h:w @> '
bash> export PS1
root@medusa:/tmp 03:01 PM>

这将在shell提示符下显示当前登录用户的名称,主机名,当前工作目录和当前时间。

4个变量,man bash 中就有这些说明,不过全英文的,没人翻译……楼主凑合看英文吧……
PS1 The value of this parameter is expanded (see PROMPTING below) and used as the primary
prompt string. The default value is ``\s-\v\$ ''.
PS2 The value of this parameter is expanded as with PS1 and used as the secondary prompt
string. The default is ``> ''.
PS3 The value of this parameter is used as the prompt for the select command (see SHELL
GRAMMAR above).
PS4 The value of this parameter is expanded as with PS1 and the value is printed before
each command bash displays during an execution trace. The first char