[英]Command line and output a different color in Mac terminal?
有什么方法可以使 Mac 终端上的命令行提示符与输出的颜色不同? 现在,一切都是相同的颜色,有时很难跟上。
不过,我已经使用过 Vagrant,现在我希望我的命令行能够从标准 Mac 终端中的其余输出文本中脱颖而出。 我知道如何改变它的颜色,但这是终端输出和提示之间共享的颜色
我使用iTerm2 ,并用定制的配色方案iterm2colorschemes 。
您可以通过修改 bash_profile 来更改它,并在其中包含您的首选项:
选项 1 结果:[time user_in_red@host_in_purple ~/Directory_in_your_computer_color ] $ commands_with_your_computer_settings
PS1="[\\t \\[$(tput setaf 9)\\]\\u\\[$(tput setaf 15)\\]@\\[$(tput setaf 12)\\]\\h \\[$(tput sgr0)\\]\\w ] \\$ "
选项 2 结果:@User_green_color~/Directory_in_green _color $ your_commands_with_your_computer_settings
PS1="@\\[$(tput setaf 2)\\]\\u\\[$(tput setaf 2)\\]\\w\\$(tput sgr0)\\] \\$ "
您可以根据需要创建自己的设置。 例如,这是颜色 2 绿色的用户。
[$(tput setaf 2)\]\u
为了修改你的 bash_profile 从你的终端输入这个。
nano ~/.bash_profile
一旦打开,粘贴您的设置、上述选项之一或您创建的选项。
保存并关闭它。 Control+x 关闭它,选择“y”保存更改,然后输入关闭它。
关闭您的终端并打开一个新终端,您应该能够看到您的更改。
对于其他颜色:
0 – 黑色。
1 – 红色。
2 - 绿色。
3 – 黄色。
4 – 蓝色。
5 – 洋红色。
6 - 青色。
7 - 白色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.