Mac OS X上的Shell提示颜色


0

我正在尝试添加颜色并在OS X Lion上自定义shell提示符,因此我编辑了.bashrc,我只能看到root帐户的差异。所以,在我用.bashrc编辑之后:

PS1="[\u][\w] :"

并运行我得到的终端

Phil:~ phil$ sudo -s
[root][~] :

但我只看到root帐户的区别。我怎样才能解决这个问题?

我想要显示:

[Phil][~] : sudo -s
[root][~] :

你可以尝试ZSH(或不同的shell)。我知道它有各种颜色和自定义。如果您只想编辑bash,我建议您将问题更改为“添加olors并自定义” 庆典 在OS X Lion上)。
— kalaracey

Answers:


0

您需要编辑该文件 .bash_profile 在您的主目录中,即 /Users/username/.bash_profile。


注意:〜/ .bash_profile由登录shell运行。 〜/ .bashrc由非登录shell运行。要确保自定义项适用于登录和非登录shell,请将常用自定义项放在〜/ .bashrc中,并使用〜/ .bash_profile运行: if [ -f $HOME/.bashrc ]; then . $HOME/.bashrc fi
— Chris Page

终端默认创建登录shell。如果你跑 bash 从登录shell创建一个非登录shell。默认情况下,子shell是非登录shell。
— Chris Page
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.