2016-05-13 53 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). 

延伸閱讀: