今までgitはデフォルトな感じで使っていたのです。
いわば武器を持たない空手の状態
そんな状態で兵共が集まるGit道場には参加できない!
というわけで下記を参考に環境を整えることにしました。
- Gitを使い始めたらやっておきたい便利な設定いろいろ
- ページャに lv を使用すると”git log”や”git diff”で表示されるテキストに変な文字列が挿入されてしまう
- zshでのgit補完機能を強化する
- zshでgitのbranch名をPROMPTに表示させるようになるまで
- zshでGitのブランチ名をプロンプトに表示する
- zsh で Git の作業コピーに変更があるかどうかをプロンプトに表示する方法
- VimmerなGit使いはfugitive.vimを今すぐ入れたほうがいい
- 今こそ!git の branch を vim のステータスラインに表示!!するとき!!!
リンク名からだいたい想像できると思いますが
1. gitのエイリアスを設定して
2. git logとか見たときの表示を修正して
3. zshのgitの補完を強化して
4. zshのプロンプトにブランチ名を表示するようにしました。
追記
5. zshのプロンプトにファイルの状況も表示するようにしました。
6. fugitive.vimを導入しました。
gitのエイリアスを設定するために$HOME/.gitconfigに下記を追加
[color] ui = true [alias] co = checkout ci = commit st = status br = branch hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short [core] excludesfile = ~/.gitignore pager = lv -c
completionのファイルを取得して.zshrcに設定を追加する。
wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash
source ${HOME}/git-completion.bash autoload -Uz add-zsh-hook autoload -Uz colors colors autoload -Uz vcs_info zstyle ':vcs_info:*' enable git svn hg bzr zstyle ':vcs_info:*' formats '[%s:%b]' zstyle ':vcs_info:*' actionformats '[%s:%b|%a]' zstyle ':vcs_info:(svn|bzr):*' branchformat '%b:r%r' zstyle ':vcs_info:bzr:*' use-simple true autoload -Uz is-at-least if is-at-least 4.3.10; then zstyle ':vcs_info:git:*' check-for-changes true zstyle ':vcs_info:git:*' stagedstr "+" zstyle ':vcs_info:git:*' unstagedstr "?" zstyle ':vcs_info:git:*' formats '%c%u[%s:%b]' zstyle ':vcs_info:git:*' actionformats '%c%u[%s:%b|%a]' fi function _update_vcs_info_msg() { psvar=() LANG=en_US.UTF-8 vcs_info [[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_" } add-zsh-hook precmd _update_vcs_info_msg RPROMPT="%1(v|%F{green}%1v%f|)"
$HOME/.vimrcにfugitive.vimの設定を追加
NeoBundleでインストール
NeoBundle 'tpope/vim-fugitive'
ステータスラインを変更
set statusline=%F%m%r%h%w[%{&ff}]%{fugitive#statusline()}%=%{g:NyanModoki()}(%l,%c)[%P]
git statusとgit diffとgit blameのキーマップを追加
nnoremap gs :<C-u>Gstatus<Enter> nnoremap gi :<C-u>Gdiff<Enter> nnoremap gb :<C-u>Gblame<Enter>
Git道場楽しみや
とりあえず設定はコピペったけどGit道場後にこの設定たちも微調整していこう。
たわごと
1ヶ月の予定です。
座間味キャンプには行きたいでござる。