Win7 安裝cygwin以及設置

安裝

  1. 先去官網下載安裝文件。cygwin_com/install_html(把下劃線換爲.)32位的選setup-x86.exe64位的選setup-x86_64.exe。下載完畢後,必定要經過郵件菜單 以管理員的身份運行 。
  2. 運行以後在選擇鏡像文件地址的時候,通常在國內都是選擇mirrors.163.com/cygwin/ 畢竟速度快些。出錯的緣由是後來出現X86和X86_64兩個文件夾,因此找不到對應的setup.ini文件了。應對的方法就是 添加具體的地址。
    若是是 32位的就添加 http://mirrors.163.com/cygwin/x86/
    若是是 64位的就添加 http://mirrors.163.com/cygwin/x86_64。
  3. 包選擇 autoconf2. ,automake1.1 ,binutil ,gcc-cor ,gcc-g ,gd ,pcre ,pcre-devel ,make ,vim ,git,python

第一次啓動時會生成Home目錄,在${cygwin}/home/${YOUR_USER_NAME}。${cygwin}表示你的cygwin安裝目錄。html

顯示設置

  1. 調整${HOME}/.bashrc文件,把註釋掉別名打開:
    ```sh
    alias df='df -h'
    alias du='du -h'python

    alias whence='type -a' # where, of a sort
    alias grep='grep --color' # show differences in colour
    alias egrep='egrep --color=auto' # show differences in colour
    alias fgrep='fgrep --color=auto' # show differences in colourgit

    alias ls='ls -h --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' #
    alias wch='which -a'
    ```
    這樣調整後,能夠ls、grep、dir輸出彩色顯示。另外加上命令的-h選項,這樣文件大小以K、M、G顯示,方便人閱讀。vim

  2. git輸出(好比log、status)彩色顯示,使用下面的命令配置:
    sh git config --global color.ui autobash

  3. vi配置
    在${HOME}/.vimrc文件中加上: # 沒有.vimrc文件就新建。
    ```sh
    set number
    set hlsearch
    set fileencoding=utf-8
    set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1ui

    set nocompatible
    set backspace=indent,eol,start編碼

    syntax enable
    ```
    說明:
    1. syntax enable:打開語法高亮。cygwin的vi缺省沒有打開。
    2. set nocompatible和set backspace:配置backspace鍵,缺省backspace不起做用。
    3. set fileencoding和set fileencodings:缺省文件編碼和自動識別文件編碼順序
    4. set number:顯示行號
    5. set hlsearch:搜索到內容高亮
  4. 配置盤符的連接
    到D盤,要/cygdrive/d,能夠新建符號連接/d,這樣能夠減小錄入(MSYS的作法)
    sh ln -s /cygdrive/c /c ln -s /cygdrive/d /d ln -s /cygdrive/e /espa

  5. 自動補全不區分大小寫
    1. ~/.bashrc文件中添加:
      sh shopt -s nocaseglob
    2. ~/.inputrc文件中添加:
      sh set completion-ignore-case on
  6. 配置按單詞移動/刪除
    1. .inputrc文件中添加:
      sh # Ctrl+Left/Right to move by whole words "\e[1;5C": forward-word "\e[1;5D": backward-word # Ctrl+Backspace/Delete to delete whole words "\e[3;5~": kill-word "\C-_": backward-kill-word
  7. Windows命令的亂碼
    1. 在用戶目錄(cd ~)裏的.bash_profile文件末尾添加以下代碼
      sh export LC_ALL=zh_CN.GBK export LC_CTYPE=zh_CN.GBK export LANG=zh_CN.GBK export XMODIFIERS=@im=Chinput3 stty cs8 -istrip stty pass8 export LESSCHARSET=latin1
    2. 一樣是~目錄,去掉.inputrc文件中一下代碼的註釋(前面的#號)
      sh set meta-flag on set convert-meta off set input-meta on set output-meta on
    3. 仍是~目錄,.bashrc文件中添加代碼
      sh alias ls='ls --color --show-control-chars'
    4. Cygwin的options設置Texts:
      • locale = zh_CN
      • Character set = GBK
    5. 重啓Cygwin。
相關文章
相關標籤/搜索