fasling
V2EX  ›  macOS

iTerm2 里 ssh 到远程机器之后 ls 没有颜色

  •  
  •   fasling · Jan 12, 2015 · 17914 views
    This topic created in 4158 days ago, the information mentioned may be changed or developed.
    iTerm2默认也没有颜色,export CLICOLOR=1之后有了颜色,凑合着也就用了。
    但是ssh到远程机器之后颜色又消失了。请问要如何配置?
    搜索到的一些方法也试过了,毫无效果。
    12 replies    2018-09-25 16:17:48 +08:00
    jsfaint
        1
    jsfaint  
       Jan 12, 2015
    没有颜色是你远端的机器的设置问题啊
    请自行alias ls="ls --clolor"
    fasling
        2
    fasling  
    OP
       Jan 12, 2015
    @jsfaint 远程机器没有问题啊,在windows下用xshell连接好好的。而且,直接ls --color也没有颜色。
    NemoAlex
        3
    NemoAlex  
       Jan 12, 2015
    export CLICOLOR="xterm-color"
    export LSCOLORS="gxfxcxdxbxegedabagacad"
    lululau
        4
    lululau  
       Jan 12, 2015
    很有可能和 terminal type 有关

    echo $TERM
    fasling
        5
    fasling  
    OP
       Jan 12, 2015
    @NemoAlex 在远程机器上和本机都都试了,没有用。
    @lululau xterm-256color
    lululau
        6
    lululau  
       Jan 12, 2015
    @fasling 你用 xshell 连接到 remote host, 在 remost host 上执行 echo $TERM,假设输出为 abc, 那么然后在 iTerm2 里执行:

    TERM=abc ssh username@remote_host
    lululau
        7
    lululau  
       Jan 12, 2015   ❤️ 1
    我记得有的发行版里有类似这样的判断:

    if [ "$TERM" = xterm ]
    then
    alias ls='ls --color'
    fi
    fasling
        8
    fasling  
    OP
       Jan 12, 2015
    @lululau 把本机的iTerm2设置为xterm,貌似就可以了.囧
    loading
        9
    loading  
       Jan 12, 2015 via Android
    1楼正解!

    @jsfaint
    Tinet
        10
    Tinet  
       Apr 28, 2016
    @fasling 我也遇到这个问题了,请问你找到原因了吗?
    fasling
        11
    fasling  
    OP
       May 1, 2016
    @Tinet 看 8 楼,我最后把本机设置为 xterm 就好了.
    fareware
        12
    fareware  
       Sep 25, 2018
    @fasling 我是本地配的 oh my zsh,然后文件没颜色,连上远程后远程有颜色。。。怎么破
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1140 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 59ms · UTC 18:07 · PVG 02:07 · LAX 11:07 · JFK 14:07
    ♥ Do have faith in what you're doing.