java cygwin 乱码_cygwin中文乱码 [转]

cygwin中文乱码 (2007-03-31 01:06:25) 标签:linux cygwin 乱码 分类:操作系统

直接执行

alias ls='ls --color --show-control-chars --time-style=long-iso'

或者把上面的内容加到/etc/profile中重启Cygwin即可。

为了使使用更方便,推荐增加如下配置信息:

1. 编辑用户home目录下的文件.inputc,去除以下几行的注释:

set meta-flag on

# 关闭bash命令行8字节字符转义符的转换

set convert-meta off

# 使bash命令行支持8字节字符输出

set output-meta on

set input-meta on

2 编辑用户home目录下的文件.bash_profile,在文件末尾加上下面几行:

alias ls='ls --color --show-control-chars --time-style=long-iso'

export LC_ALL=zh_CN.GB23122

export LC_CTYPE=zh_CN.GB2312

export LANG=zh_CN.GB2312

export XMODIFIERS="@im=Chinput"3

stty cs8 -istrip

stty pass8

# Update: 少了这个less就不支持中文了

export LESSCHARSET=latin1

.bash_profile

# 让ls和dir命令显示中文和颜色

alias ls='ls --show-control-chars --color'

alias dir='dir -N --color'

# 设置为中文环境,使提示成为中文

export LANG="zh_CN.GBK"

# 输出为中文编码

export OUTPUT_CHARSET="GBK".inputrc

# 关闭bash命令行8字节字符转义符的转换

set convert-meta off

# 使bash命令行支持8字节字符输入

set input-meta on

# 使bash命令行支持8字节字符输出

set output-meta on

set meta-flag on

set completion-ignore-case on

cygwin在win中享受linux的特质新一篇: 回头想想--关于接口的问题 | 旧一篇: eFace 1.0.0 发布:java版本的XAML/WPF     如果你一直习惯于windows的操作,不会发现win的控制台有什么不好的,因为也许压根就不会用到它。不过如果你使用过linux后,被其强大的命令 行模式折服的时候,再返回到win底下操作的时候发现比较难受,尝过了甜头就比较难以舍弃。正如你所想的cygwin就是移植linux的程序到 windows中,那样你可以用vim、可以用ls、可以用命令行的ssh一切你在linux底下习惯了的东西,当然cygwin的功能远远不止这些,还 可以编译linux程序,当然这不是本次的议题。

1、下载安装:

cygwin有两种安装模式,一是下载全部的整合包,直接安装。二是下载setup.exe在线安装需要的功能。比较推崇第二种,可以定制自己需要的功能。下载setup

运行setup.exe

2007-10-31_124345.jpg

2007-10-31_124358.jpg

    2007-10-31_124431.jpg

2007-10-31_124411.jpg

2007-10-31_124422.jpg

选择一个比较快的镜像下载组件

2007-10-31_124446.jpg

2007-10-31_124502.jpg

组件选择(如vim默认是不安装的,但是却是很有用的,选择edittor->vim点击skip选择版本)

2007-10-31_124613.jpg

接下来要做的是泡杯茶等组件下载完成,顺利的话不到半杯喝完就安装好了,在桌面上有个cygwin的图片

点击打开。

2、不出意外,你打开的界面会出现乱码。cygwin默认的设置不支持中文,需要一些些小小的调教

在安装目录下如:C:\cygwin\home\Administrator(用户名)

1)、修改.baserc

# base-files version 3.7-1

# To pick up the latest recommended .bashrc content,

# look in /etc/defaults/etc/skel/.bashrc

# Modifying /etc/skel/.bashrc directly will prevent

# setup from updating it.

# The copy in your home directory (~/.bashrc) is yours, please

# feel free to customise it to create a shell

# environment to your liking. If you feel a change

# would be benificial to all, please feel free to send

# a patch to the cygwin mailing list.

# User dependent .bashrc file

# Shell Options

# #############

# See man bash for more options...

# Don't wait for job termination notification

# set -o notify

# Don't use ^D to exit

# set -o ignoreeof

# Use case-insensitive filename globbing

# shopt -s nocaseglob

# Make bash append rather than overwrite the history on disk

# shopt -s histappend

# When changing directory small typos can be ignored by bash

# for example, cd /vr/lgo/apaache would find /var/log/apache

# shopt -s cdspell

# Completion options

# ##################

# These completion tuning parameters change the default behavior of bash_completion:

# Define to access remotely checked-out files over passwordless ssh for CVS

# COMP_CVS_REMOTE=1

# Define to avoid stripping description in --option=description of './configure --help'

# COMP_CONFIGURE_HINTS=1

# Define to avoid flattening internal contents of tar files

# COMP_TAR_INTERNAL_PATHS=1

# If this shell is interactive, turn on programmable completion enhancements.

# Any completions you add in ~/.bash_completion are sourced last.

# case $- in

#   *i*) [[ -f /etc/bash_completion ]] && . /etc/bash_completion ;;

# esac

# History Options

# ###############

# Don't put duplicate lines in the history.

# export HISTCONTROL="ignoredups"

# Ignore some controlling instructions

# export HISTIGNORE="[   ]*:&:bg:fg:exit"

# Whenever displaying the prompt, write the previous line to disk

# export PROMPT_COMMAND="history -a"

# Aliases

# #######

# Some example alias instructions

# If these are enabled they will be used instead of any instructions

# they may mask. For example, alias rm='rm -i' will mask the rm

# application. To override the alias instruction use a \ before, ie

# \rm will call the real rm not the alias.

# Interactive operation...

# alias rm='rm -i'

# alias cp='cp -i'

# alias mv='mv -i'

# Default to human readable figures

# alias df='df -h'

# alias du='du -h'

# Misc :)

# alias less='less -r'                          # raw control characters

# alias whence='type -a'                        # where, of a sort

# alias grep='grep --color'                     # show differences in colour

# Some shortcuts for different directory listings

# alias ls='ls -hF --color=tty'                 # classify files in colour

# alias dir='ls --color=auto --format=vertical'

# alias vdir='ls --color=auto --format=long'

# alias ll='ls -l'                              # long list

# alias la='ls -A'                              # all but . and ..

# alias l='ls -CF'                              #

# Functions

# #########

# Some example functions

# function settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; }

2)、修改.inputrc

# base-files version 3.7-1

# To pick up the latest recommended .inputrc content,

# look in /etc/defaults/etc/skel/.inputrc

# Modifying /etc/skel/.inputrc directly will prevent

# setup from updating it.

# The copy in your home directory (~/.inputrc) is yours, please

# feel free to customise it to create a shell

# environment to your liking. If you feel a change

# would be benifitial to all, please feel free to send

# a patch to the cygwin mailing list.

# the following line is actually

# equivalent to "\C-?": delete-char

"\e[3~": delete-char

# VT

"\e[1~": beginning-of-line

"\e[4~": end-of-line

# kvt

"\e[H": beginning-of-line

"\e[F": end-of-line

# rxvt and konsole (i.e. the KDE-app...)

"\e[7~": beginning-of-line

"\e[8~": end-of-line

# VT220

"\eOH": beginning-of-line

"\eOF": end-of-line

###################### 以下为添加部分 ################################

# 关闭bash命令行8字节字符转义符的转换

set convert-meta off

# 使bash命令行支持8字节字符输入

set input-meta on

# 使bash命令行支持8字节字符输出

set output-meta on

# 让bash的命令行已vi模式执行,屏蔽掉下面一行,BASH的命令行操作

# 就像vi中编辑文本一样,默认为INSERT模式,可以在BASH启动后直接

# 输入:set -o vi,来启动该开关,set +o vi关闭该模式,但在cygwin

# 中调用set +o vi关闭时会出现一些乱码,估计也是一个BUG

#set editing-mode vi

# Allow 8-bit input/output

#set meta-flag on

#set convert-meta off

#set input-meta on

#set output-meta on

#$if Bash

# Don't ring bell on completion

#set bell-style none

# or, don't beep at me - show me

#set bell-style visible

# Filename completion/expansion

#set completion-ignore-case on

#set show-all-if-ambiguous on

# Expand homedir name

#set expand-tilde on

# Append "/" to all dirnames

#set mark-directories on

#set mark-symlinked-directories on

# Match all files

#set match-hidden-files on

# 'Magic Space'

# Insert a space character then performs

# a history expansion in the line

#Space: magic-space

#$endif

启动后界面

2007-10-31_131001.jpghttp://blog.csdn.net/xwkp2008/archive/2007/10/31/1859331.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值