打造cygwin

ZhaxPonder posted @ Aug 19, 2009 12:02:30 PM in other with tags cygwin , 14807 readers

使用过e-texteditor的朋友会发现e在安装过程中会有一个安装cygwin的提示,倘若不安装它,e中很多bundle的功能将无法使用。究其原因,e将cygwin当做了默认的bundle执行环境,因此ruby、python、perl等脚本无法运行。幸运的是,通过简单的bundle环境设置,可以避免这个问题。

那什么是cygwin呢?cygwin其实是一个在windows上运行的linux模拟环境,你可以在上面使用ls、pwd、mkdir等命令,也可以在上面尝试vim、emacs等工具,对于依赖windows却又想体验linux的朋友来说,它未尝不是一个练手的好平台。cygwin的安装较为简单,但要注意几个地方:

  1. 找一个好的镜像,试过几个国外的,等了几十分钟,结果安装包下载到一半报错退出,让人极其郁闷;

  2. 倘若你选择全部安装,请做好损失3.3G硬盘空间以及等上几个钟头的心理准备。

安装完之后,在桌面上会自动生成一个快捷方式,双击运行,你会发现,你启动了以前只能在linux下才能看到的bash,以及,一个让人冲动的粗糙界面。还是先静下心来,把cygwin整合到windows上吧。方法很简单,假设你的cygwin安装路径是c:/cygwin,则将c:/cygwin/bin添加到系统变量path中,个人推荐加到windows前,如此对于相同命令,会执行cygwin的命令,而非windows的,譬如find。现在你在cmd下也能使用cygwin的命令了。

只剩下两个问题了:

  1. 操作界面粗糙得让人无法忍受,包括字体、颜色以及窗体大小;
  2. 不支持中文。

在中文操作系统里,cygwin的默认字体是新宋体,窗口大小为80x25字符长,未免让人遗憾。以前自己想了个比较笨的解决办法:将系统语言改成英文后,右键点快捷方式属性,在font项选择lucida console字体(至少是程序员偏爱的字体),同时根据自己屏幕大小手动设置layout的window size。呵呵,相信没有人愿意陪我一起犯傻。幸好有puttycyg,让一切都变得简单。puttycyg是putty的增强版本,可作为windows下免费的telnet、rlogin和ssh客户端,也同时具有充当本地cygwin终端的能力。在puttycyg下可以自定义界面样式,包括字体样式、颜色、大小的定义和全屏显示。运行putty,在window的appearance下修改字体,同时将script改成chinese gb2312(为putty支持中文输入作准备),之后回到session,在command框中写入“-”,connection type选为cygterm,对session命名,保存,之后为putty创建快捷方式,右键点击快捷方式,在shortcut下修改target,加入-load [你的session名](中括号不需要)。以后双击putty快捷方式,你就能马上进入自己定义的cygwin界面了。

接下来解决cygwin中文支持的问题。修改cygwin/home/[你的用户名]下的.inputrc和.bashrc文件:在.inputrc中加入

set meta-flag on
set convert-meta off
set input-meta on
set output-meta on
set completion-ignore-case on

在.bashrc中加入

export LC_ALL=zh_CN.UTF-8
export export LC_CTYPE=zh_CN.UTF-8
export LANG=zh_CN.UTF-8
stty cs8 -istrip
stty pass8
export LESSCHARSET=latin1
alias ls='ls -hF --color=tty --show-control-chars'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'

重启cygwin,键入中文,显示正常,一切ok。

 

Avatar_small
Patrick said:
Aug 19, 2009 08:21:54 PM

好牛B啊~~第一个comments。。。

xq262144 said:
Oct 21, 2010 06:29:56 AM

老问题,新解答。。export LC_TYPE那些不用zh_CN用en_US.UTF-8也可以的。。

AAA said:
Apr 09, 2022 07:07:16 PM

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. 온라인카지노

AAA said:
May 03, 2022 04:45:09 AM

You are so cool man, the post on your blogs are super great . how to sell payment processing services

 

 

====================================================

 

 

The secrets of why News and why it means a lot. Merchant Service Commission


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter