2016-05-13 28 views
-1

当我尝试通过使用Iterm2或OSX Terminal尝试ssh到服务器时,我正面临一些奇怪的行为。基本上,使用tab自动完成时的问题是,它会打印多了一个随机的额外字符到底,例如:redhat中的标签和箭头键奇怪的行为

//the 'e' is extra in this case 
$ cd keys/e 

,并试图使用任何箭头键进行导航时,它基本上不一切工作。

//^[[C^[[C^[[C^[[C^[[C^[[C^[[C are printed by pressing arrow keys 
$ cd keys/^[[C^[[C^[[C^[[C^[[C^[[C^[[Ce 

//Kernel Version 
OS Version: 2.6.39-400.246.2.el6uek.x86_64 

//Distribution Information 
$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.6 (Santiago) 

但它工作得很好,在我的MacBook,我猜它是由我的服务器配置文件中设置造成的,但我有双重检查,我没有任何的以下文件在我的家乡:

$ vi .bash_profile 
$ vi .bashrc 

任何帮助将不胜感激。

+0

问题是不清楚,因为'^ [[C'(右箭头)不用于在壳“导航”。您可能会发现终端和“TERM”设置不匹配的问题,但没有可帮助人们回答的详细信息。 –

+0

当我说'导航'时,我的意思是在我输入的命令之间进行导航。 –

回答

1

我弄明白了,这是因为我在服务器的默认shell是ksh,需要请求系统管理员将其更改为bashzsh

顺便说一句,我真的很讨厌那些无缘无故提出问题的人,这有点不高兴,如果你不喜欢这个问题,你可以忽略它。

1

你所谓的“导航”是行编辑的一部分。

如果您使用ksh,以最好地利用其行编辑功能的方法是打开emacs模式:

set -o emacs 

显然KSH的开发者没有使用vi,因为VI-模式非常有限。但是,emacs模式是默认模式。

在您的问题,光标-键在正常模式(所述^[[字符),其被假定如果TERM=linux,而其它终端通常使用应用模式^[O字符)。如果您的TERM设置不正确,则可能会导致ksh混淆。有些人在他们的shell初始化中定义了别名,以使shell可以工作。

参见示例Make Arrow and delete keys work in KornShell command line。在这个问题的答案的解决方案,应该为你工作,因为RHEL6(和CentOS6)使用KSH-93:

Name  : ksh       Relocations: (not relocatable) 
Version  : 20120801       Vendor: CentOS 
Release  : 28.el6_7.3     Build Date: Tue Sep 22 11:08:59 2015 
Install Date: Mon Mar 28 16:22:50 2016   Build Host: c6b9.bsys.dev.centos> 
Group  : System Environment/Shells  Source RPM: ksh-20120801-28.el6_7.3> 
Size  : 1743023       License: EPL 
Signature : RSA/SHA1, Tue Sep 22 14:35:03 2015, Key ID 0946fca2c105b9de 
Packager : CentOS BuildSystem <http://bugs.centos.org> 
URL   : http://www.kornshell.com/ 
Summary  : The Original ATT Korn Shell 
Description : 
KSH-93 is the most recent version of the KornShell by David Korn of 
AT&T Bell Laboratories. 
KornShell is a shell programming language, which is upward compatible 
with "sh" (the Bourne Shell). 

延伸阅读: