Search code examples
tig

unable to use external command in tig


I use git and gitk a lot. Recently, I found some enthousiastic posts about tig and decided to give it a try. It looks great for viewing the repository, however changing the repo with tig seems difficult if not unworkable.

The problem I am facing is that tig fails to start an editor for external commands, thus making it impossible to continue with the action. For example, if I select a commit and issue

!git commit --amend

I get a screen saying

vim: Warning: Output is not to a terminal 

Only ^C gets me out, thus stopping tig as well.

What can I do to configure this properly for either tig or git in order to get this working?

thanks in advance, Ruud


Solution

  • The main way to start external commands is via keybindings and what in Tig is referred to as user-defined commands. For example, to amend the last commit you can add the following to ~/.tigrc after which pressing + will put you right into Vim:

    bind generic + !git commit --amend
    

    There are several variables for the browsing state, which can be passed to external commands, such as %(commit) and %(branch) as well as %(prompt) for asking for input, for example when creating a branch.

    For reference, the !<command> allows to open the output in the pager, for example !git show 3e3abcd and as such is more like Vim's :r!<command>.