Livid
406.45D
549.31D
V2EX  ›  macOS

让 OS X Terminal 里的 ls 也有颜色

  •  1
     
  •   Livid ·
    PRO
    · Jan 5, 2014 · 14649 views
    This topic created in 4695 days ago, the information mentioned may be changed or developed.
    在 .profile 里加入:

    export CLICOLOR=1
    export LSCOLORS=exfxcxdxbxexexabagacad
    22 replies  •  1970-01-01 08:00:00 +08:00
    alexrezit
    alexrezit
    Jan 5, 2014
    1
    $ alias l
    alias l='ls -FG'
    kqz901002
    kqz901002
    Jan 5, 2014❤️1
    2
    bash的话
    export CLICOLOR=1
    export GREP_OPTIONS="--color=auto" 这样就可以

    zsh得像楼主这样
    Livid
    Livid
    MOD
    OP
    PRO
    Jan 5, 2014
    3
    @kqz901002
    @alexrezit

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

    tree 也会有高亮
    bigclean
    bigclean
    Jan 5, 2014
    8
    可以使用 gnu coreuils 中的 ls 替代 bsd ls,其支持 dircolors,搭配 solarized 主题(https://github.com/seebi/dircolors-solarized/)使用非常方便。
    duoxing
    duoxing
    Jan 5, 2014
    9
    添加了之后,ls确实有颜色了,但是对目录的颜色不是很满意,在什么地方可以改呢?
    duoxing
    duoxing
    Jan 5, 2014
    10
    好了,知道在什么地方改了,改好了,谢谢,请忽略上面那条
    run2
    run2
    Jan 5, 2014
    11
    @duoxing 估计只有直接改配色方案了,github里很多 terminal color scheme
    Owenjia
    Owenjia
    Jan 5, 2014
    12
    https://github.com/seebi/dircolors-solarized
    ls的话,我用的这个~~
    leebo
    leebo
    Jan 5, 2014
    13
    oh my zsh 哈哈 肯定有人会说这个吧
    hackevin
    hackevin
    Jan 5, 2014
    14
    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
    kqz901002
    Jan 5, 2014
    15
    @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
    sinxccc
    Jan 5, 2014
    16
    @kqz901002 locale
    kevinroot
    kevinroot
    Jan 5, 2014
    17
    用的zsh自带的主题:robbyrussell.zsh-theme看着挺舒服的的
    dorentus
    dorentus
    Jan 5, 2014
    18
    > 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
    jokefun
    Jan 6, 2014❤️1
    19
    hackevin
    hackevin
    Jan 6, 2014
    20
    @dorentus 自己编译的
    rzer0
    rzer0
    Jan 6, 2014
    21
    ls -G 就可以显示颜色。
    TankyWoo
    TankyWoo
    Jan 6, 2014
    22
    mac os 下 我记得是 alias ls="ls -G" 就可以了

    另外,配合zsh,控制不同后缀文件显示不同颜色:

    https://github.com/tankywoo/dotfiles/blob/master/tanky.zsh-theme
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3198 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 10:10 · PVG 18:10 · LAX 02:10 · JFK 05:10
    ♥ Do have faith in what you're doing.