Reputation: 39155
I am using vim-fugitive and adding %{fugitive#statusline()}
to the statusline nicely displays the current git branch.
But what about a git file status indicator (like in a git status
output)?
For example when an opened file is untracked, staged, clean etc. the indicator would display it in the statusline via '[?]', '[M]', '[C]' or something like that.
How to add such a indicator?
Upvotes: 9
Views: 3766
Reputation: 2902
This will show a +
if the current file is modified:
system("[[ -n \"$(git status --porcelain " . shellescape(expand("%")) . ")\" ]] && echo -n +")
As a vim-powerline segment:
Upvotes: 2
Reputation: 53644
You can try out my aurum plugin, with it one-character status indicator is %{Powerline#Functions#aurum#GetStatus()}
. But note that one of the goals of the aurum is to hide VCS differences behind a plugin interface, so there are six statuses: added, unknown, modified, removed, deleted, ignored, clean: all derived from mercurial; and there are no statuses like “modified in index” (it is just “modified”).
For all statuses except “clean” uppercased first letter is displayed, for “clean” nothing is displayed at all. Use aurum#status()
if you want to change this, Powerline#Functions#aurum#GetStatus()
is just a two-line wrapper for aurum#status()
function for use in powerline, no need to create a wrapper for a wrapper if you want to change the behavior.
Upvotes: 2