msysgit在windows下默认用的是cmd作为终端,虽然可以设置快速编辑模式启用复制粘贴,但使用起来还是很不方便,而且很慢。偶然发现bin目录下有个rxvt,试用了下还不错,就是界面太难看了。然后在网上找到一篇cygwin下修改rxvt界面的文章

首先编辑文件~/.Xdefaults,内容如下:

! ~/.Xdefaults - X default resource settings
Rxvt*geometry: 120x40
Rxvt*background: #000020
Rxvt*foreground: #ffffbf
!Rxvt*borderColor: Blue
!Rxvt*scrollColor: Blue
!Rxvt*troughColor: Gray
Rxvt*scrollBar: True
Rxvt*scrollBar_right: True
Rxvt*font: Fixedsys
Rxvt*mfont: Terminal
Rxvt*SaveLines: 2000
Rxvt*loginShell: True
! VIM-like colors
Rxvt*color0: #000000
Rxvt*color1: #FFFFFF
Rxvt*color2: #00A800
Rxvt*color3: #FFFF00
Rxvt*color4: #0000A8
Rxvt*color5: #A800A8
Rxvt*color6: #00A8A8
Rxvt*color7: #D8D8D8
Rxvt*color8: #000000
Rxvt*color9: #FFFFFF
Rxvt*color10: #00A800
Rxvt*color11: #FFFF00
Rxvt*color12: #0000A8
Rxvt*color13: #A800A8
Rxvt*color14: #00A8A8
Rxvt*color15: #D8D8D8
! eof

然后修改你的c:\cygwin\cygwin.bat文件,使用rxvt来替代cmd.exe:

@echo off
C:
chdir C:\cygwin\bin
set EDITOR=vi
set VISUAL=vi
set CYGWIN=codepage:oem tty binmode title
rxvt -e bash --login -i

我在Xdefault中已经设置了中文字体,不过要想正常的显示和输入中文,还需要更改几个文件。在文件~/.bashrc中增加如下内容:

# Chinese locale
export LANG=zh_CN.GBK
export OUTPUT_CHARSET="GBK"

# Display Chinese
alias ls='ls --show-control-chars --color'
alias dir='ls --show-control-chars'
alias less='less --raw-control-chars'

如果~/.bash_profile还未存在,那么创建它,并添加如下内容:

# Exec .bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

另外再创建一个~/.inputrc文件,内容如下:

# Chinese input/output in bash
set meta-flag on
set input-meta on
set output-meta on
set convert-meta off
set completion-ignore-case on

好了,现在可以使用rxvt做为cygwin的终端了。

 

不过启动的时候还是有点问题,按文章中的bat写法配置文件不能生效,但先进入msysgit后输入“rxvt -e bash –login -i ”则可以用到配置文件。

所以我修改了下~/.bashrc来启动rxvt:

# Chinese locale
export LANG=zh_CN.GBK
export OUTPUT_CHARSET="GBK"

# Display Chinese
alias ls='ls --show-control-chars --color'
alias dir='ls --show-control-chars'
alias less='less --raw-control-chars'

if [ "x$RXVT_STARTED" = "x" ]
	then
		export RXVT_STARTED="yes"
		rxvt -e bash --login -i
fi

使用方法不变,还是运行msysgit目录下的msys.bat即可。可以在桌面创建一个msys.bat的快捷方式,然后设置其起始位置为你的工作目录。
缺点是启动rxvt后后面的bat窗口还在,而且不能关。关了bat窗口rxvt也会被关掉。
不过用了rxvt后发现速度还是不快,主要是在git目录下用tab键自动补全会很慢,暂时没找到解决方案。
http://jingyan.baidu.com/article/93f9803fd3a4dde0e46f55f5.html
http://easwy.com/blog/archives/use-rxvt-in-cygwin/

Published in git, Windows XP
Tags: ,

No Responses to “windows 下msysgit使用rxvt做终端”

Leave a Reply

请输入算式结果(看不清请点击图片)
(必须)