emacs的tramp连接远程挂掉的问题解决

大约从去年的年初开始,我通过emacs就没办法正常的通道ssh访问远程系统中的内容了。这 个问题一直困扰着我,以致于我都想完全切换到vim了,这也是我现在使用的配置中使用了 evil-mode的由来。

其实这个问题在我这边表现的比较怪异,比如,我通过pscp访问openwrt的路由器,则没有 问题,访问远程的某个服务器(ubuntu系统),也没有问题,访问raspberry pi,有问题, 访问远程windows中的cygwin(我开通了cygwin的ssh服务),有问题。总之,看上去既和 操作系统有些关系,又和一部分软件有关,我甚至使用了默认的安装也是相同的结果。

从去年年初到现在,问题就这么一直困扰着我,虽然我尽量避免这种情况,但心头始终牵挂 着。直到上周,我重新在考虑shell的问题的时候,发现了端倪。

很早之前从网上便获知,shell可能会引起一部分问题,但我所有的测试环境都使用的是相 同的shell: bash,关于相关shell的设置,我也做了制定,但都没有解决我的问题。上周我 在连接局域网中的电脑和阿里云的远程主机的时候,发现这两个都可以访问,局域网中的电 脑用的是ubuntu 12.04,而阿里云用的是14.04(没记错的话),而家里的e9卡片式电脑, 却不可以,e9卡片式电脑用的是ubuntu 12.04,三个用的都是bash,甚至版本都有相同的。 但我注意到,e9卡片式电脑中的shell的PS1部分出现的是带颜色的,而其他的两个都不是带 颜色的,而从emacs的*Messages*中来看,出现下面的日志:

Unable to load color “PaleYellow” [2 times] Tramp: Opening connection for rix@172.10.1.199 using pscp… Tramp: Sending command `plink -l rix -ssh 172.10.1.199 && exit || exit’

Tramp: Waiting for prompts from remote shell Tramp: Sending password Tramp: Sending command `plink -l rix -ssh 172.10.1.199 && exit || exit’ Tramp: Opening connection for rix@172.10.1.199 using pscp…done Unable to load color “PaleYellow”

我注意到了有一个颜色相关的,我不知道这个到底是什么,无论是远程还是本地,我都没办 法找到这个叫”PaleYellow”的颜色相关内容。不过, 我找到了远程主机中与shell的PS1相 关的内容:

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  # We have color support; assume it's compliant with Ecma-48
  # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  # a case would tend to support setf rather than setaf.)
  color_prompt=yes
    else
  color_prompt=
    fi
fi

如果注释掉force_color_prompt=yes这一行,PS1将不会出现颜色,而这样一来,emacs访问 远程也正常了。

原来问题在这儿。。。。。

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据