Livid
277.99D
569.5D
V2EX  ›  macOS

让 OS X Terminal 里的 ls 也有颜色

  •  1
     
  •   Livid ·
    PRO
    · Jan 5, 2014 · 14188 views
    This topic created in 4516 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
        1
    alexrezit  
       Jan 5, 2014
    $ alias l
    alias l='ls -FG'
    kqz901002
        2
    kqz901002  
       Jan 5, 2014   ❤️ 1
    bash的话
    export CLICOLOR=1
    export GREP_OPTIONS="--color=auto" 这样就可以

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

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

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

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

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