summaryrefslogtreecommitdiff
path: root/content/post/2008-06-26-git-branch-everywhere.md
diff options
context:
space:
mode:
authorFranck Cuny <franckcuny@gmail.com>2016-07-02 20:06:31 -0700
committerFranck Cuny <franckcuny@gmail.com>2016-07-02 20:06:31 -0700
commit4b8e43f75b394a4e6169884fbfb4c606865c6a22 (patch)
tree48cae6b8e8f9b68cae29676d8a15cb3ddbfcccda /content/post/2008-06-26-git-branch-everywhere.md
parentStop using Jekyll. (diff)
downloadlumberjaph-4b8e43f75b394a4e6169884fbfb4c606865c6a22.tar.gz
Import migration from Jekyll to Hugo.
All the posts were converted, and the layout is created. This looks like it works just fine.
Diffstat (limited to 'content/post/2008-06-26-git-branch-everywhere.md')
-rw-r--r--content/post/2008-06-26-git-branch-everywhere.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/content/post/2008-06-26-git-branch-everywhere.md b/content/post/2008-06-26-git-branch-everywhere.md
new file mode 100644
index 0000000..5667e67
--- /dev/null
+++ b/content/post/2008-06-26-git-branch-everywhere.md
@@ -0,0 +1,38 @@
+---
+date: 2008-06-26T00:00:00Z
+summary: In which I share a snippet of code to display a git branch in vim.
+title: Git branch everywhere
+---
+
+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):
+
+```vim
+set statusline=%&lt;[%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:
+
+```vim
+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).