Skip to content

Show status flag of repo in statusline #219

wants to merge 2 commits into from

3 participants

elien122 commented Jul 3, 2012

This is customizing the fugitive statusline for showing status flags which indicate current repository status.
like $(__git_ps1) of git-completion.bash in linux shell.

I wrote this tweak a couple of month ago just for my taste.
By chance i stopped by your github site, and i saw someone who needs this feature.
(issue #206, #197)

Tested on WinXP-x86, Ubuntu- Vim version on both platform is 7.3.566
I hope this will help.

elien122 added some commits Jul 4, 2012
@elien122 elien122 Show status flag of repo in statusline
Status flags of .git repository are shown next to the branch name as

Try to mimic '$(__git_ps1 " (%s)")' of 'git-completion.bash'

  # dirty_flag - '*': modified, but not staged flag
                 '+': staged (to be committed) flag
  # stash_flag - '$': something is stashed
  # untracked  - '%': there're untracked files

In vim, checking repo_status is done by calling 'git' externally,
vim-user can be tormented with severe performance degradations.
Accordingly, makes status checking as less as possible - only when
.git/index is modified, and files in .git work tree are modified.

To enable this feature, declare below variables somewhere in vimrc

    let g:fugitive_stl_showdirtystate = 1
    let g:fugitive_stl_showstashstate = 1
    let g:fugitive_stl_showuntrackedfiles = 1
@elien122 elien122 Combine repo_state variables into one Dictionary
Several variables which contain the repo status are combined into single

Also, git_index_mod_time_old gets changed its type into buffer(b:) due
to support the situation when multiple 'index' files exist in one work
tree, such as submodule.
@stardiviner stardiviner commented on the diff Oct 2, 2012
@@ -12,6 +12,21 @@ if !exists('g:fugitive_git_executable')
let g:fugitive_git_executable = 'git'
+"initialize variables for repo_status_flag on statusline
+" to enable status_flag feature declare below 'g:fugitive_stl_show...' variables somewhere in your vimrc setting
+let s:repo_state = {'dirty': {'unstaged': '' , 'staged': ''}, 'stash': '' , 'untracked': ''}
stardiviner added a note Oct 2, 2012

Seems there are some status not implemented ?? check out here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
blueyed commented Dec 13, 2014

Do you still use this? Have you improved it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.