diff options
| author | Franck Cuny <franck.cuny@gmail.com> | 2016-08-10 14:33:04 -0700 |
|---|---|---|
| committer | Franck Cuny <franck.cuny@gmail.com> | 2016-08-10 20:17:56 -0700 |
| commit | 8d7d02f42c3947f756c18cb4d37d9d97fbd0d27d (patch) | |
| tree | a6cecddaaea7e87d901a6c28bebe3a531438f24b /posts/2008-06-26-git-branch-everywhere.md | |
| parent | Merge branch 'convert-to-org' (diff) | |
| download | lumberjaph-8d7d02f42c3947f756c18cb4d37d9d97fbd0d27d.tar.gz | |
convert back to md
Diffstat (limited to '')
| -rw-r--r-- | posts/2008-06-26-git-branch-everywhere.md | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/posts/2008-06-26-git-branch-everywhere.md b/posts/2008-06-26-git-branch-everywhere.md new file mode 100644 index 0000000..a7ad9ef --- /dev/null +++ b/posts/2008-06-26-git-branch-everywhere.md @@ -0,0 +1,32 @@ +The current trend is to have the name of the current git branch everywhere. Personnaly I display it in my vim's status bar, and in my zsh prompt. + +Here is my vimrc configuration for this (I'm not the author of this function, and can't remember where I saw it first): + +``` viml +set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff}%{g:gitCurrentBranch}%{']'}%y\ %F%=%l,%c%V%8P +autocmd BufEnter * :call CurrentGitBranch() + +let g:gitCurrentBranch = '' +function! CurrentGitBranch() + let cwd = getcwd() + cd %:p:h + let branch = matchlist(system('/usr/local/git/bin/git branch -a --no-color'), '\v\* (\w*)\r?\n') + execute 'cd ' . cwd + if (len(branch)) + let g:gitCurrentBranch = '][git:' . branch[1] . '' + else + let g:gitCurrentBranch = '' + endif + return g:gitCurrentBranch +endfunction +``` + +and my zshrc: + +``` sh +local git_b +git_b='$(get_git_prompt_info '%b')' +PROMPT="%(?..%U%?%u:) $git_b %40>...<%/%(#.%U>%u.%B>%b) " +``` + +with the following script [S55\_git](http://www.jukie.net/~bart/conf/zsh.d/S55_git). |
