在ansi-term中使用ssh时,Shell会提示重复 [英] Shell prompt repeating when using ssh in ansi-term
问题描述
当我使用SSH从emacs的安全会话登录到Ubuntu 12.04机器时,提示显示不正确:
When I use SSH to login to a Ubuntu 12.04 machine from an ansi-term session in emacs the prompt displays incorrectly:
0;ubuntu@jumplin: ~ubuntu@jumplin:~$
这应该如下所示:
ubuntu@jumplin:~$
我已经尝试了一些关于utf-8和颜色支持的建议,但是它们似乎没有工作(颜色目前在ansi-term中工作正常):
I've tried a few of the suggestions in relation to utf-8 and colour support however they don't seem to be working (colour currently works fine in ansi-term):
我认为这可能与一个不支持的ansi转义码或类似的东西有关,但我不是很确定 - 值对于此终端会话的PS1为:
I think it might have something to do with a unsupported ansi escape code or something like that, but I'm not really sure - the value of PS1 for this terminal session is:
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
任何建议都会非常感激:)当终端会话中出现奇怪的字符时,我总是似乎有点失落。 / p>
Any advice would be much appreciated :) I always seem to get a bit lost when strange characters show up in terminal sessions.
推荐答案
\ [\e] 0; \u @ \h:\w您的提示中的\a\]
是配置您的xterm(?)的标题栏。即使ANSI颜色由 ansi-term
支持,操作标题栏的转义序列也不是。这就是为什么你看到提示重复两次 - 第一部分应该去标题栏。
\[\e]0;\u@\h: \w\a\]
in your prompt is to configure your xterm(?)'s title bar. Even though ANSI colorization is supported by ansi-term
, the escape sequences that manipulate title bar are not. That is why you see the prompt repeated twice - the first section is supposed to go to the title bar.
所以要么从你的PS1中删除第一个序列,要么做类似的事情关于 Bash Prompt HOWTO 中的建议:
So either remove the first sequence from your PS1 or do something similar to what is suggested in Bash Prompt HOWTO:
function proml
{
case $TERM in
xterm*)
local TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
local TITLEBAR=''
;;
esac
PS1="${TITLEBAR}\
[\$(date +%H%M)]\
[\u@\h:\w]\
\$ "
PS2='> '
PS4='+ '
}
在 ansi-term
中, TERM
将等于 eterm-color
。
这篇关于在ansi-term中使用ssh时,Shell会提示重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!