问题描述
我是OS X的新手,在使用Ubuntu Linux一段时间后刚获得一台Mac.我要弄清楚的许多事情是终端窗口中没有颜色-如运行ls -la
或git status
...
I'm new to OS X, having just gotten a Mac after working with Ubuntu Linux for some time. Among the many things I'm trying to figure out is the absence of colors in my terminal window - like the ones that are shown (on Linux) when running ls -la
or git status
...
我只是不知道如何激活外壳中的颜色.
I just can't figure out how to activate colors in my shell.
推荐答案
这是我发现的启用全局终端颜色.
Here is a solution I've found to enable the globalterminal colors.
在主目录中编辑.bash_profile
(自OS X 10.8起)-或(对于10.7及更低版本):.profile
或.bashrc
或/etc/profile
(取决于可用性)并添加以下代码:
Edit your .bash_profile
(since OS X 10.8) — or (for 10.7 and earlier): .profile
or .bashrc
or /etc/profile
(depending on availability) — in your home directory and add following code:
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
CLICOLOR=1
只需启用终端的着色即可.
CLICOLOR=1
simply enables coloring of your terminal.
LSCOLORS=...
指定如何给特定项目上色.
LSCOLORS=...
specifies how to color specific items.
编辑.bash_profile
后,启动终端并通过执行以下命令来强制进行更改:
After editing .bash_profile
, start a Terminal and force the changes to take place by executing:
source ~/.bash_profile
然后转到Terminal > Preferences
,单击Profiles
选项卡,然后单击Text
子选项卡并选中Display ANSI Colors
.
Then go to Terminal > Preferences
, click on the Profiles
tab and then the Text
subtab and check Display ANSI Colors
.
在Sierra上验证(2017年5月).
这篇关于OS X终端颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!