让 OS X Terminal 里的 ls 也有颜色

2014-01-05 15:34:14 +08:00
 Livid
在 .profile 里加入:

export CLICOLOR=1
export LSCOLORS=exfxcxdxbxexexabagacad
13031 次点击
所在节点    macOS
22 条回复
alexrezit
2014-01-05 15:44:55 +08:00
$ alias l
alias l='ls -FG'
kqz901002
2014-01-05 15:45:07 +08:00
bash的话
export CLICOLOR=1
export GREP_OPTIONS="--color=auto" 这样就可以

zsh得像楼主这样
Livid
2014-01-05 15:46:05 +08:00
@kqz901002
@alexrezit

谢谢,这是我最喜欢 V2EX 的一点,我知道肯定会有人提出更好的做法。
Livid
2014-01-05 15:46:47 +08:00
@kqz901002 我发现如果不加入最后一行,颜色的配置方式貌似和 Ubuntu 上显示的不一样。
kqz901002
2014-01-05 15:48:55 +08:00
@Livid 这样啊,可能跟colorscheme有关系, http://equation85.github.io/blog/customize-terminal-on-mac/
kqz901002
2014-01-05 15:49:59 +08:00
@Livid
@alexrezit
感觉oh-my-zsh默认的就已经很舒服了
https://github.com/robbyrussell/oh-my-zsh
jasontse
2014-01-05 15:52:20 +08:00
Linux bash 我是这么做的
export LS_OPTIONS='--color=auto'
alias ls='ls $LS_OPTIONS'

tree 也会有高亮
bigclean
2014-01-05 16:03:34 +08:00
可以使用 gnu coreuils 中的 ls 替代 bsd ls,其支持 dircolors,搭配 solarized 主题(https://github.com/seebi/dircolors-solarized/)使用非常方便。
duoxing
2014-01-05 16:12:48 +08:00
添加了之后,ls确实有颜色了,但是对目录的颜色不是很满意,在什么地方可以改呢?
duoxing
2014-01-05 16:15:19 +08:00
好了,知道在什么地方改了,改好了,谢谢,请忽略上面那条
sobigfish
2014-01-05 16:15:52 +08:00
@duoxing 估计只有直接改配色方案了,github里很多 terminal color scheme
Owenjia
2014-01-05 16:21:22 +08:00
https://github.com/seebi/dircolors-solarized
ls的话,我用的这个~~
leebo
2014-01-05 17:31:18 +08:00
oh my zsh 哈哈 肯定有人会说这个吧
hackevin
2014-01-05 20:33:25 +08:00
drwxr-xr-x+ 5 hackevin staff 170 [2013-12-21 22:15] Public/
drwx------+ 3 hackevin staff 102 [2013-12-21 22:15] Movies/

-----------------------------------------------------------------

[hackevin.iNULLMBA] $ bash --version
GNU bash, version 4.3.0(1)-rc1 (x86_64-apple-darwin13.0.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

[hackevin.iNULLMBA] $ brew install coreutils

[hackevin.iNULLMBA] $ cat .profile
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
alias ls='ls -F -rt --color=auto --time-style=+"[%Y-%m-%d %H:%M]"'
kqz901002
2014-01-05 21:45:56 +08:00
@hackevin
➜ ~ bash --version
GNU bash, 版本 4.2.45(2)-release (i386-apple-darwin13.0.2)
Copyright (C) 2011 Free Software Foundation, Inc.
许可证 GPLv3+: GNU GPL 许可证版本3或者更高 <http://gnu.org/licenses/gpl.html>

这是自由软件,您可以自由地更改和重新发布。
在法律允许的范围内没有担保.

竟然是中文的 吓尿我了
sinxccc
2014-01-05 23:14:35 +08:00
@kqz901002 locale
kevinroot
2014-01-05 23:24:02 +08:00
用的zsh自带的主题:robbyrussell.zsh-theme看着挺舒服的的
dorentus
2014-01-05 23:49:44 +08:00
> export CLICOLOR=1
之后就有颜色了吧,LSCOLORS 似乎是用来设置颜色的?


@hackevin 你的 bash 是自己装的?怎么版本这么高……
我的 OS X 10.9.1 (13B42) 自带的 /bin/bash 才是 3.2.51:

> GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
> Copyright (C) 2007 Free Software Foundation, Inc.

homebrew 带的 bash stable 也只是 4.2.45 而已啊……
jokefun
2014-01-06 00:58:34 +08:00
hackevin
2014-01-06 01:01:26 +08:00
@dorentus 自己编译的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/95737

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX