title: Vim: Show current git branch in lightline status line without fugitive
body: <p>I am using <a href="https://github.com/itchyny/lightline.vim" rel="nofollow">lightline.vim</a> and I would like to show the current git branch. At the moment, I am doing so using <a href="https://github.com/tpope/vim-fugitive" rel="nofollow">vim-fugitive</a>, however, I do not use this plugin at all, except for showing the git branch in the status line.</p>
  
  <p>My question is:</p>
  
  <p>Is there a way to show the git branch in the status line without using fugitive?</p>
  
  <p>I tried to create a custom function that I hooked to lightline. The function fetched the current git branch using the <code>system</code> vimscript function. It (didn't) work well, except that the status line was refreshed on every keystroke, which broke everything else and made vim unusable. Essentially, the git branch was being fetched using the <code>system</code> function on every keystroke...</p>
  
  <p>So that's not a viable solution. What I "could" do, is create a global variable which says whether or not the git branch was fetched, and prevent the custom function from fetching the branch name again if it was already fetched. Then I could fetch the branch name again every time MacVim loses focus (not sure how to do that using terminal vim). That is not ideal though...</p>
  
  <p>Any ideas on how to solve this problem please?</p>