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?
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.
This will show a +
if the current file is modified:
system("[[ -n \"$(git status --porcelain " . shellescape(expand("%")) . ")\" ]] && echo -n +")
As a vim-powerline segment:
https://github.com/twe4ked/dotfiles/blob/bd0f98531d3467e041af1b8f17556e0052389735/vim/plugin_config/powerline.vim#L1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With