Cyginw セットアップまとめ 200901版

cygwin_jeからパッケージインストール出来なくなっていたりとか、シェルをzshに変えたとかで使い方が変わって昔の手順が使えなくなったのでもう一度


とりあえず、setup.exeを落として実行

インストール

まずは何はともあれパッケージのインストールから。

パッケージのダウンロード先は

適当に日本ドメインのリングサーバを選ぶ

パッケージ選択
  • Devel
  • Doc
    • man
  • Editor
  • Interpreters
  • Net
    • openssh
  • Shells
  • Utils
    • lv
    • screen
  • Web

からrxvtのバイナリを取ってくる

環境設定

Windows環境変数

HOMEC:\Documents and Settings\%USERNAME%\My Documentsに設定
とりあえず、起動

マウントポイント変更

ホームディレクトリのマウント場所を設定する

mount -u "${USERPROFILE}\My Documents" /home/${USERNAME}

こうすることで、所謂「マイ ドキュメント」がホームになるので作業がし易くなる

cygwin_jeからとってきたrxvtの展開

tar -xjvf rxvt.tar.bz2 -C /

C:\cygwin\bin\rxvt.exeのショートカットをデスクトップに作成し、リンク先をC:\cygwin\bin\rxvt.exe -e /bin/zsh --login -iに変更する。ショートカットからCygwinを起動

~/.vimrcの編集
set number
if &encoding != 'utf-8'
    set encoding=japan
    set fileencoding=japan
endif
set fileencodings=UTF-8,CP932,EUC-JP

set sw=4
set ts=4
set sts=0
set si
set backspace=indent,eol,start
set laststatus=2
set nobackup
set showcmd
set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P

syntax on
~/.Xdefaultsの編集
Rxvt.foreground:white
Rxvt.background:black
Rxvt.geometry: 100x50
Rxvt.font: Osaka−等幅-16
Rxvt.mfont: Osaka−等幅-16-jisx0208
Rxvt.multichar_encoding: sjis
Rxvt.visualBell: True
Rxvt.saveLines: 3000
Rxvt.scrollBar_right: True
Rxvt.color12:DeepSkyBlue
~/.zshenvの編集
SHELL=zsh

if [ -d $HOME/bin ];then
    if ! echo $PATH | /bin/grep $HOME/bin > /dev/null;then
    export PATH=$HOME/bin:$PATH
    fi  
fi

export PAGER=lv

alias o='/bin/cygstart'
alias grep='grep --color'
alias ls='ls -hF --show-control-chars --color=tty'
alias today='/bin/data +%Y%m%d'
alias ftp='/bin/ncftp'
alias lv='/bin/lv -c -Os'

alias -g L='| lv'
alias -g H='| head'
alias -g T='| tail'
~/.zshrcの編集
# Created by newuser for 4.3.6

bindkey -v

setopt prompt_subst

# プロンプト設定
case "$TERM" in
  xterm|kterm|mterm|rxvt*)
  PROMPT='%{^[[33m%}%m%B[%D %T]%b%{^[[m%}\$ '
  RPROMPT='[%{^[[33m%}%4c%{^[[m%}]'
  ;;
  screen*)
  PROMPT='%{^[[33m%}%m%B[%D %T]%b%{^[[m%}\$ '
  RPROMPT='[%{^[[33m%}%4c%{^[[m^[k%c^[\\%}]'
  ;;
esac

autoload -U colors
colors

autoload -U compinit
compinit -u

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

setopt no_flow_control
setopt no_beep
setopt ignore_eof
setopt auto_list
setopt extended_glob
setopt auto_cd
setopt auto_pushd
setopt no_tify

# history setting {{{
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups
setopt share_history
setopt hist_ignore_space
setopt hist_expand
# }}}

bindkey -a 'O' push-line
bindkey -a 'H' run-help
bindkey -a '^A' vi-beginning-of-line
bindkey -a '^E' vi-end-of-line
bindkey -v '^[OH' vi-beginning-of-line
bindkey -v '^[OF' vi-end-of-line

# GNU screen setting
case "${TERM}" in
  screen*)
  alias man='set_title man'
  ;;
esac

function set_title(){
  echo -ne "^[k$@^[\\"
  "$@"
}
function preexec(){
  if [[ $TERM = screen* ]];then
    echo -ne "^[k${PWD/${HOME}/~}\$ $1^[\\"
  else
    echo -ne "\033]0;${PWD/${HOME}/~}\$ $1\007"
  fi
}
function chpwd(){
  if [[ $TERM = screen* ]];then
    echo -ne "^[k${PWD/${HOME}/~}^[\\"
  else
    echo -ne "\033]0;${PWD/${HOME}/~}\007"
  fi
  ls -A
}

# vim: sw=2 ts=2 sts=0 fdm=marker:
~/.screenrcの編集
startup_message off 
#defbce on
#term xterm-256color
shell $SHELL
escape ^@^@
defencoding sjis

hardstatus string "[screen %n %t] %h"
#caption always "%{= wk} %-w%{=bu dr}%n %t%{-}%+w"
caption always "%{= wk} %-w%{=bu dr}%n %t%{-}%+w %= %{=b wb}%y/%m/%d %{=b wb}%c"

shelltitle "$ |$SHELL"

bind = resize =
bind + resize +1
bind - resize -1
bind _ resize max 

その他

CygwinパッケージのSubversionはマルチバイトに難があるので、Windows用をsubversion: ドキュメント & ファイル: Windows Apache 2.2.xからとって来て適当なところに展開し、~/bin/以下に実行ファイルのシンボリックリンクを張る。