summaryrefslogtreecommitdiff
path: root/_posts/2008-06-26-git-branch-everywhere.textile
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-09-10 23:25:10 +0200
committerfranck cuny <franck@lumberjaph.net>2010-09-10 23:25:10 +0200
commit0afbfaee75e8480e8e0ed0a3bbd3749a4756f727 (patch)
treef9e4d91866060661d53c50c66973fcd20600983f /_posts/2008-06-26-git-branch-everywhere.textile
downloadlumberjaph-0afbfaee75e8480e8e0ed0a3bbd3749a4756f727.tar.gz
initial import
Diffstat (limited to '_posts/2008-06-26-git-branch-everywhere.textile')
-rw-r--r--_posts/2008-06-26-git-branch-everywhere.textile38
1 files changed, 38 insertions, 0 deletions
diff --git a/_posts/2008-06-26-git-branch-everywhere.textile b/_posts/2008-06-26-git-branch-everywhere.textile
new file mode 100644
index 0000000..1c32000
--- /dev/null
+++ b/_posts/2008-06-26-git-branch-everywhere.textile
@@ -0,0 +1,38 @@
+---
+layout: post
+category: app
+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):
+
+{% highlight bash %}
+set statusline=%&lt;[%n]%m%r%h%w%{'['.(&amp;fenc!=''?&amp;fenc:&amp;enc).':'.&amp;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
+{% endhighlight %}
+
+and my zshrc:
+
+{% highlight bash %}
+local git_b
+git_b='$(get_git_prompt_info '%b')'
+PROMPT="%(?..%U%?%u:) $git_b %40&lt;...&lt;%/%(#.%U&gt;%u.%B&gt;%b) "
+{% endhighlight %}
+
+with the following script "S55_git":http://www.jukie.net/~bart/conf/zsh.d/S55_git