V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
fasling
V2EX  ›  macOS

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

  •  
  •   fasling · 2015-01-12 14:51:27 +08:00 · 17153 次点击
    这是一个创建于 3413 天前的主题,其中的信息可能已经有所发展或是发生改变。
    iTerm2默认也没有颜色,export CLICOLOR=1之后有了颜色,凑合着也就用了。
    但是ssh到远程机器之后颜色又消失了。请问要如何配置?
    搜索到的一些方法也试过了,毫无效果。
    12 条回复    2018-09-25 16:17:48 +08:00
    jsfaint
        1
    jsfaint  
       2015-01-12 15:52:11 +08:00
    没有颜色是你远端的机器的设置问题啊
    请自行alias ls="ls --clolor"
    fasling
        2
    fasling  
    OP
       2015-01-12 15:59:36 +08:00
    @jsfaint 远程机器没有问题啊,在windows下用xshell连接好好的。而且,直接ls --color也没有颜色。
    NemoAlex
        3
    NemoAlex  
       2015-01-12 16:13:04 +08:00
    export CLICOLOR="xterm-color"
    export LSCOLORS="gxfxcxdxbxegedabagacad"
    lululau
        4
    lululau  
       2015-01-12 16:18:00 +08:00
    很有可能和 terminal type 有关

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

    TERM=abc ssh username@remote_host
    lululau
        7
    lululau  
       2015-01-12 20:28:54 +08:00   ❤️ 1
    我记得有的发行版里有类似这样的判断:

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

    @jsfaint
    Tinet
        10
    Tinet  
       2016-04-28 20:04:27 +08:00
    @fasling 我也遇到这个问题了,请问你找到原因了吗?
    fasling
        11
    fasling  
    OP
       2016-05-01 21:53:34 +08:00
    @Tinet 看 8 楼,我最后把本机设置为 xterm 就好了.
    fareware
        12
    fareware  
       2018-09-25 16:17:48 +08:00
    @fasling 我是本地配的 oh my zsh,然后文件没颜色,连上远程后远程有颜色。。。怎么破
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2547 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 02:34 · PVG 10:34 · LAX 19:34 · JFK 22:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.