vimからはてなを更新
てすと。
zshrcの設定
結構弄ったので晒しておく。
SPROMPTをGoogleっぽくしてみた。
export LANG=ja_JP.UTF-8 export LSCOLORS=ExFxCxdxBxegedabagacad PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting alias ls='ls -G' alias la='ls -a' alias ll='ls -ltr' alias grep='grep --color=auto' alias vi='/usr/local/bin/vi' # 関数 find-grep () { find . -type f -print | xargs grep -n --binary-files=without-match $@ } # cd をしたときにlsを実行する function chpwd() { ls } # keybindをviにする bindkey -v # history保存設定 HISTFILE=~/.zsh_history HISTSIZE=50000 SAVEHIST=50000 setopt hist_ignore_dups # ignore duplication command history list setopt share_history # share command history data setopt hist_no_store # ヒストリにhistoryコマンドを記録しない setopt hist_reduce_blanks # 余分なスペースを削除してヒストリに記録する setopt magic_equal_subst # コマンドラインの引数で --prefix=/usr などの = 以降でも補完できる # history-searchをCtrl+PとCtrl+Nで 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 # 補完 autoload -U compinit compinit zstyle ':completion:*' list-colors 'di=;34;1' 'ln=;35;1' 'so=;32;1' 'ex=31;1' 'bd=46;34' 'cd=43;34' setopt list_packed # 補完をつめて表示 setopt nolistbeep # ビープ音を鳴らさない # C-s, C-qを無効にする。 setopt no_flow_control # no remove postfix slash of command line setopt noautoremoveslash # cd履歴 "cd -[タブ]" setopt auto_pushd # auto cd ディレクトリ名のみ打ち込むとcd setopt auto_cd # 打ち間違い訂正 setopt correct_all # prompt color設定 autoload colors colors case ${UID} in 0) PROMPT="%B%{${fg[magenta]}%}%/#%{${reset_color}%}%b " PROMPT2="%B%{${fg[magenta]}%}%_#%{${reset_color}%}%b " SPROMPT="%B%{${fg[magenta]}%}Did you mean %{${fg[yellow]}%}%r%{${reset_color}%} ? [n,y,a,e]:%{${reset_color}%}%b " [ -n "${REMOTEHOST}${SSH_CONNECTION}" ] && PROMPT="%{${fg[magenta]}%}${HOST%%.*} ${PROMPT}" ;; *) PROMPT="%{${fg[white]}%}%/%%%{${reset_color}%} " PROMPT2="%{${fg[white]}%}%_%%%{${reset_color}%} " SPROMPT="%{${fg[white]}%}Did you mean %B%{${fg[yellow]}%}%r%{${reset_color}%}%b ? [n,y,a,e]:%{${reset_color}%} " [ -n "${REMOTEHOST}${SSH_CONNECTION}" ] && PROMPT="%{${fg[white]}%}${HOST%%.*} ${PROMPT}" ;; esac # ターミナルのタイトル case "${TERM}" in kterm*|xterm) precmd() { echo -ne "\033]0;${USER}@${HOST%%.*}:${PWD}\007" } ;; esac
Vundle→NeoBundle
速攻すぎるがこういうのは最初のほうがいいので。
最近はNeoBundle最強らしいので移行する。
cd ~/dotfiles/
rm -rf .vim
git submodule add https://github.com/Shougo/neobundle.vim.git
vi ~/dotfiles/.vimrc
configはこのへん参考。
http://d.hatena.ne.jp/sugilog/20111101/1320158226
dotfilesをgithubで、プラグインはvundleで
http://d.hatena.ne.jp/oovu70/20120324/p1
ここがすごく参考になった。
のでほぼトレースだけどメモ。
dotfilesをgithub管理にする
mkdir ~/dotfiles cd ~/dotfiles git init mv ~/.zshrc ~/dotfiles/ mv ~/.vimrc ~/dotfiles/ mv ~/.vim ~/dotfiles/ ln -snf ~/dotfiles/.zshrc ~/ ln -snf ~/dotfiles/.vimrc ~/ ln -snf ~/dotfiles/.vim ~/ git add ./ git commit -m 'first commit' git remote add origin git@github.com:adorechic/dotfiles.git git push -u origin master
みなさんシンボリックリンクはるところはMakefileにしたりシェル書いたりしてるみたいだけどとりあえずは直接はった。
vimrcがしょぼいけどこれを機にvim人生やり直そうとしているので見逃してください。
Vundleをいれてみる
cd ~/dotfiles
git submodule add git://github.com/gmarik/vundle.git .vim/vundle.git
vi ~/dotfiles/.vimrc
set nocompatible filetype off set rtp+=~/.vim/vundle.git/ call vundle#rc() Bundle 'The-NERD-tree' filetype plugin indent on " NERD Tree config nmap <silent> <C-e> :NERDTreeToggle<CR> vmap <silent> <C-e> <Esc>:NERDTreeToggle<CR> omap <silent> <C-e> :NERDTreeToggle<CR> imap <silent> <C-e> <Esc>:NERDTreeToggle<CR> cmap <silent> <C-e> <C-u>:NERDTreeToggle<CR> autocmd vimenter * if !argc() | NERDTree | endif autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif let g:NERDTreeIgnore=['\.clean$', '\.swp$', '\.bak$', '\~$'] let g:NERDTreeShowHidden=1 let g:NERDTreeMinimalUI=1 let g:NERDTreeDirArrows=0
しれっとためしにNERD treeをいれてみる。
configはhttp://blog.livedoor.jp/kumonopanya/archives/51048805.html を参考にした。
そしたらvimをたちあげて
:BundleInstall
で、OK。
NERD treeはCtrl-eで開閉。Ctrl-wwでフォーカス切り替え。
echo '.vim/bundle' > .gitignore
zshをいれてみる
いろいろこのへん慣れていこうと思っている。
とりあえずzshから。
brewでさくっと。
$ brew install zsh
$ sudo cp -a /etc/zshenv /etc/zprofile
zshrc
alias ls='ls -G' alias ll='ls -ltr' alias grep='grep --color=auto' alias vi='/usr/local/bin/vi' PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting autoload -U compinit compinit
とりあえず最小限。
最後の2行がないとzshの補完が意味ない。
pythonでMultiPart-POST
easy_installをいれたのはこれがやりたかっただけ。
$ easy_install MultipartPostHandler
#!/usr/bin/python import urllib2 import MultipartPostHandler opener = urllib2.build_opener(MultipartPostHandler.MultipartPostHandler) url = "http://hoge.com/upload" post_data = {"filename":"sample.png", "file" : open("sample.png", "rb")} open = opener.open(url, post_data)
ちなみにopenするときのrbはread+binaryの意味。画像とかだとbinary指定しないとぶっこわれるかも。
virtual-python.pyとeasy_install
pythonでgemに相当するものが、easy_installっていうらしい。
あとrvmっぽいものがvirtual-python。
virtual-pythonをいれる
$ curl -O http://peak.telecommunity.com/dist/virtual-python.py
$ python virtual-python.py
実行すると、~/bin, ~/lib, ~/include ができる。
インストール先ディレクトリの設定をする。
$ vi ~/.pydistutils.cfg [install] install_lib = ~/lib/python2.4/site-packages install_scripts = ~/bin
パスを指定する。
$ vi ~/.bash_profile PYTHONPATH=$HOME/lib/python2.4/site-packages/ # HOMEのを先にする PATH=$HOME/bin:$PATH export PATH export PYTHONPATH $ source ~/.bash_profile $ which python ~/bin/python
easy_installを入れる
$ curl -O http://peak.telecommunity.com/dist/ez_setup.py
$ python ez_setup.py
完了。使ってみる場合は
$ easy_install MultipartPostHandler
こんな感じ。