summaryrefslogtreecommitdiff
path: root/posts/2008-06-26-git-branch-everywhere.org
diff options
context:
space:
mode:
authorFranck Cuny <franckcuny@gmail.com>2016-08-04 11:45:44 -0700
committerFranck Cuny <franckcuny@gmail.com>2016-08-04 11:45:44 -0700
commit585b48b6a605cb71ef99dd767880e1b7ee5bf24e (patch)
treec65377350d12bd1e62e0bdd58458c1044541c27b /posts/2008-06-26-git-branch-everywhere.org
parentUse Bullet list for the index. (diff)
parentMass convert all posts from markdown to org. (diff)
downloadlumberjaph-585b48b6a605cb71ef99dd767880e1b7ee5bf24e.tar.gz
Merge branch 'convert-to-org'
Diffstat (limited to '')
-rw-r--r--posts/2008-06-26-git-branch-everywhere.org36
1 files changed, 36 insertions, 0 deletions
diff --git a/posts/2008-06-26-git-branch-everywhere.org b/posts/2008-06-26-git-branch-everywhere.org
new file mode 100644
index 0000000..959696a
--- /dev/null
+++ b/posts/2008-06-26-git-branch-everywhere.org
@@ -0,0 +1,36 @@
+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):
+
+#+BEGIN_EXAMPLE
+ 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
+#+END_EXAMPLE
+
+and my zshrc:
+
+#+BEGIN_EXAMPLE
+ local git_b
+ git_b='$(get_git_prompt_info '%b')'
+ PROMPT="%(?..%U%?%u:) $git_b %40>...<%/%(#.%U>%u.%B>%b) "
+#+END_EXAMPLE
+
+with the following script
+[[http://www.jukie.net/~bart/conf/zsh.d/S55_git][S55\_git]].