jonas / tig

Text-mode interface for git
https://jonas.github.io/tig/
GNU General Public License v2.0
12.5k stars 612 forks source link

How to bind a key for multiple commands(internal command + external shell command)? #935

Open c02y opened 5 years ago

c02y commented 5 years ago

For instance, I want to bind a key in ~/.tigrc like this:

bind generic    v    :source ~/.tigrc ; :echo "~/.tigrc reloaded!"

to source ~/.tigrc and then print the message that the file is reloaded.

and another binding like:

bind generic    E    !>sh -c "vim ~/.tigrc" ; :source ~/.tigrc ; :echo "~/.tigrc reloaded!"

to edit ~/.tigrc using vim and source it after quitting vim, and then print the message

But it seems they don't work. So is it possible to bind a key for multiple commands which contains both internal command and external shell command? If the answer is yes, what should I do?

EricCousineau-TRI commented 2 years ago

Same use case here; would like to add a "quick tag" button, then refresh the view (so I can mark two commits, then easily compare) - related to #553.

Ideally could do something like this -- similar to Cody's, but using \; to mimic tmux

bind main <F2> +bash -c 'git tag -f tig-f2 %(commit); echo "Tag 'tig-f2': %(commit)"' \; refresh

That being said, looking at options, seems like I can do set refresh-mode after-command: https://jonas.github.io/tig/doc/tigrc.5.html#_variables

ideasman42 commented 1 year ago

I've run into a similar use case:

It's handy to be able to drop a stash in the stash view.

bind stash Q !@git stash drop %(stash) --quiet

However the diff doesn't refresh, set refresh-mode = after-command doesn't work either, not sure if that's a bug or not.

liangkarl commented 7 months ago

I've run into a similar use case:

It's handy to be able to drop a stash in the stash view.

bind stash Q !@git stash drop %(stash) --quiet

However the diff doesn't refresh, set refresh-mode = after-command doesn't work either, not sure if that's a bug or not.

The latest commit should fix this problem. https://github.com/jonas/tig/issues/1323