您的位置:首页 > 其它

Cygwin安装及环境配置

2008-02-10 21:15 253 查看
1. 关于term的问题, 如果嫌安装的term不够pp,可以使用putty,那就需要安装openssh包,以便可以使用putty, openssh的安装过程参阅http://pigtail.net/LRP/printsrv/cygwin-sshd.html 里面介绍的很详细。下面挑几个关键点记录如下:

(2b)

Download cygwin's setup.exe from http://www.cygwin.com/ and save setup.exe in c:/cygwin
Click Start...Run...and type c:/cygwin/setup.exe

If you are asked about "Just Me" or "All Users", choose "All Users"

When it asks for "Local Package Directory", type c:/cygwin
When a selection screen comes up, (you can resize the windows to see better)
click the little View button for "Full" view

,
find the package "openssh", click on the word "skip" so that an

appears in Column B,
see this illustration.

Click

to start installing cygwin and ssh.
Size of the basic cygwin system is about 40 Meg, this may take a while.

Take a coffee break.


(3) Right click My Computer, Properties, Advanced, Environment Variables
See this illustration (red dots)
Click the "New"

button to add a new entry to system variables:
variable name is CYGWIN
variable value is ntsec

(4) Right click My Computer, Properties, Advanced, Environment Variables
See this illustration (green dots)
Select the Path variable and click the "Edit"

button:
append ;c:/cygwin/bin to the end of the existing variable string.

(5) Open a cygwin window (by double clicking the

icon), a black screen pops open, type
ssh-host-config (on slower computers, it may take several minutes to generate the dsa keys)When the script asks you about "privilege separation", answer yes
When the script asks about "create local user sshd", answer yes
When the script asks you about "install sshd as a service", answer yes
When the script asks you for "CYGWIN=" your answer is ntsec

See Note 5 below if you need to run ssh-host-config again.

(6) While you are still in the (black) cygwin screen, start the sshd service
net start sshd
or
cygrunsrv --start sshd

Note: if you need to stop the sshd service, pop open a

cygwin window
net stop sshd or cygrunsrv --stop sshd

(7) Make sure every Windows user has a password set, if not,
go to

Control Panel....User Accounts and create a password.

(8)

Pop a cygwin

window, harmonize Windows user information with cygwin, otherwise they cannot login
mkpasswd --local > /etc/passwd
mkgroup --local > /etc/group

Test to see if sshd is working, pop a cygwin

window (note: the command below is case sensitive)
whoami
ssh localhost

or
ssh "$USERNAME@127.0.0.1"


If you get a prompt without error messages, type
ls -lh /cygdrive/c
if you see a directory listing, success!






(type exit to end the cygwin ssh session)

If you have a Windows username that contain space, expand the space into / [space],
e.g. if the Windows login name is mickey mouse
ssh mickey/ mouse@127.0.0.1

2. Putty现在可以连接到本机上了,界面的字体pp多了吧:) 接下来是几个个性化的设置。

首先是 shell的设置

修改 $HOME/.bashrc文件,找到修改或者添加如下部分:

# Use the command line history just as in linux
set -o vi

# Interactive operation...
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias more='less'

# 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' #

这样你的shell就可以显示pp的目录颜色了。

3. 接下来是vim的设置

在$HOME/目录下建立.vimrc文件,内容如下:

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Download: http://napali.ch/stotz/config/vim.tgz
" File: $HOME/.vimrc
" Version: 1.0.4
" Date: 2004-07-11
" Author: Urs Stotz <stotz@gmx.ch>
" Comment: Please send me suggestion for improvement
" Tested on: Debian and Sun Solaris.
" For vim and gvim you will need only .vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Changelog
" 1.0.4 tests templates for perl and perlmodules
" 1.0.3 new perl dictionary
" 1.0.2 smale changes
" 1.0.1 fix ttyscroll it was slowly
" 1.0.0 Init Version
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim settings "
""""""""""""""""
" version 6.0
" set autoindent
" the same as |:set backspace=indent,eol,start|
set backspace=2
" keyword completion with dictionary the command is: |i_CTRL-X_CTRL-K|

" xterm backspace settings
if &term == "xterm"
set t_kb=^?
fixdel
endif

if &term == "xterm"
set t_kD=^[[3~
endif

set dict=~/.vim/dict/perl,~/.vim/dict/programming,~/.vim/dict/american
set formatoptions=tcqr
" by a compressed helpfile
" set helpfile=$VIMRUNTIME/doc/help.txt.gz
set incsearch
" always show status line
set laststatus=2
" use extended regular expressions
set magic
set nobackup
" use Vim features
set nocompatible
" quiet and peaceful (your colleges thanks you)
set noerrorbells
" exrc is a potential security leak
set noexrc
" I don't like hlsearch
set nohlsearch
set nonumber
set wrap
" show the cursor position all the time
set ruler
" Show (partial) command in status line.
set showcmd
set showmode
set smartindent
" create new window below current one
set splitbelow
set suffixes=.bak,~,.swp,.o,.info,.aux,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
" Don't wrap words by default
set textwidth=0
" For terminals where scrolling is very slow and redrawing is not slow.
" set ttyscroll=3
set viminfo=/"200,%,'200,/100,:100,@100,f1,h,n~/.vim/viminfo
" wildmenu : command-line completion operates in an enhanced mode
set wildmenu

"""""""""""
" tabstop "
"""""""""""
" see :help 'tabstop'
set shiftwidth=4
set tabstop=4
set smarttab
set expandtab

""""""""""""""
" c settings "
""""""""""""""
set cindent
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case

""""""""""""""""""
" color settings "
""""""""""""""""""
if !has ("gui_running")
" if vim in a terminal
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set the colors for vim on "xterm" - not necessary on all systems "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if &term =~ "xterm-debian" || &term =~ "xterm-xfree86" || &term =~ "xterm"
set t_Co=16
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
" http://www-2.cs.cmu.edu/~maverick/VimColorSchemeTest/index-perl.html
colorscheme default
set background=dark
" hi Normal ctermfg=white ctermbg=black
" hi PreProc ctermfg=gray ctermbg=black
else
"set guifont=fixed
"set guifont=Monospace/ 10
" http://www-2.cs.cmu.edu/~maverick/VimColorSchemeTest/index-perl.html
colorscheme blackbeauty
set background=dark
" colorscheme default
" set background=light
" hi PreProc guifg=#c0c0c0 guibg=#000040
" hi Normal guifg=black guibg=white
endif

if has("syntax") && &t_Co > 2
syntax on
endif

""""""""""
" maping "
""""""""""
" useful for changelog the Dateformat is in ISO8601
" map #log mq:r!date +"/%Y-/%m-/%d /%H:/%M:/%S $ <$@$>"`qJ
map #log mq:r!date +"/%Y/%m/%dT/%k/%M/%S Urs Stotz <stotz@gmx.ch>"`qJ
" map CTRL-] to // (useful by german keyboards)
map //

""""""""""""""""""""""""""""""""""""""
" Additional settings and parameters "
""""""""""""""""""""""""""""""""""""""
filetype plugin on
filetype indent on

""""""""""""
" Plugins: "
""""""""""""
" set ctags for the plugin taglist command is |:Tlist| see |:help taglist|
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
" open the tags file
map [I:let nr = input("Which one: ")exe "normal " . nr ."[/t"
noremap :cal VimCommanderToggle()

" http://www.vim.org/scripts/script.php?script_id=65
" au BufEnter * execute ":lcd " . expand("%:p:h")

""""""""""""""
" Templates: "
""""""""""""""
":set verbose=9
" :command! -nargs=1 Templ :set ft=| :0r! ~/.vim/templates/perl %

""""""""""""""""""""""""""""
" Plugins in ~/.vim/plugin "
""""""""""""""""""""""""""""
" ~/.vim/plugin/DirDiff.vim
" :DirDiff dir1 dir2
" vim ~/.vim/plugin/DirDiff.vim
"
" ~/.vim/plugin/MakeDoxygenComment.vim
" :Dox
" vim ~/.vim/plugin/MakeDoxygenComment.vim
"
" ~/.vim/plugin/bufexplorer.vim
" /be - To start exploring in the current window
" /bs - To start exploring in a newly split window
" /bv - To start exploring in a newly split window
" :he bufexplorer
"
" ~/.vim/plugin/grep.vim
" :Grep - Grep for the specified pattern in the specified files
" :Rgrep - Run recursive grep
" :GrepBuffer - Grep for a pattern on all open buffers
" :GrepArgs - Grep for a pattern on all the Vim argument filenames
" :Fgrep - Run fgrep
" :Rfgrep - Run recursive fgrep
" :Egrep - Run egrep
" :Regrep - Run recursive egrep
" :Agrep - Run agrep
" :Ragrep - Run recursive agrep
" vim ~/.vim/plugin/grep.vim
"
" ~/.vim/plugin/info.vim
" :Info info
" vim ~/.vim/plugin/info.vim
"
" ~/.vim/plugin/manpageview.vim
" :Man man
" :he manpageview
"
" ~/.vim/plugin/matchit.vim
" % - Cycle forward through matching groups
" g% - Cycle backwards through matching groups
" :he matchit
"
" ~/.vim/plugin/taglist.vim
" :Tlist
" :he taglist
"
" ~/.vim/plugin/tar.vim
" :e foobar.tgz
" vim ~/.vim/plugin/tar.vim

这可以使得vim能高亮显示代码,便于编辑文件。

只是不够满意的一点是vim的backspace 在putty里面变成了shift+backspace才好使。

可以用fixdel修复,但是好像不能保存

If your delete key terminal code is wrong, but the
code for backspace is alright, you can put this in
your .vimrc:
:fixdel
This works no matter what the actual code for
backspace is.
If the backspace key terminal code is wrong you can
use this:
:if &term == "termname"
: set t_kb=^V
: fixdel
:endif
Where "^V" is CTRL-V and "" is the backspace key
(don't type four characters!). Replace "termname"
with your terminal name.

可以在vim编辑界面下输入 :h fixdel来参考详细的说明, 不过在cygwin的term下似乎vim是正常的。

4. 对于cygwin下没有more命令的问题,可以用less代替,用关了more,就在.bashrc里做一alias即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: