9

I really like Fugitive (VIM git wrapper plugin) However I would like to create a script that starts vim and then runs

:Gstatus 

immediately. However when I try

vim -c Gstatus

I get an error stating that Gstatus is not an editor command

Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
  • At that point in your session, the fugitive plugin is probably not loaded or unable to work its magic. Can you do `:GStatus` right after you started Vim without any file? – romainl Feb 04 '13 at 08:22
  • 1
    It seems fugative doesn't work unless there is a file loaded which is part of a git repository. The current directory satisfies that condition so starting gvim with the current directory as the current file works. See My answer below. – bradgonesurfing Feb 04 '13 at 08:31

5 Answers5

6

vim +Gstatus +only works. I have it aliased to vimg

jsm3031
  • 61
  • 1
  • 2
4

This works

gvim -c 'Gstatus | wincmd j | hide' .

makes the fugative window full size and hide the directory explorer buffer. Also with the directory buffer hidden when you quit the fugative buffer vim closes

bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
  • I prefer using `vim -c Gstatus .` since gives me a window to see diffs (pressing `D` on the cursor line) without closing the status window. – Ricardo Stuven Feb 19 '13 at 11:10
  • 1
    The `.` directory trick doesn't work when NERDTree plugin is enabled, but `.` can be replaced by any other filename that doesn't exist. – Ricardo Stuven Feb 19 '13 at 11:15
  • Just YFI for PowerShell/Windows users - `.` did NOT work for me as the file argument to Vim, so as Ricardo suggested, all I did was use `temp` as the file name. (Vim only creates the swap file for `temp`). – Tahir Hassan Oct 06 '17 at 20:39
1

You can do this (assuming you are in the project root dir):

$ vim -c 'view .git/index'

It opens the git index in read-only mode (mimicking the essentials of the :Gstatus command)

Markus Coetzee
  • 3,384
  • 1
  • 29
  • 26
  • You don't have the rich mappings available like with `:Gstatus` but it works for committing. – kba May 26 '16 at 20:24
1

As a slight improvement on bradgonesurfing's answer

vim -c 'Gstatus | wincmd o' .

This works even if you have splitbelow set

Lewis R
  • 433
  • 5
  • 9
0

Run vim +Git +only

I got here thanks to @jsm3031's answer, which nudged me in the right direction.

Miron Veryanskiy
  • 343
  • 7
  • 12