jonas / tig

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

Default main view / jump to "Staged/Unstaged changes" #1329

Open andree182 opened 2 months ago

andree182 commented 2 months ago

An (via tigrc or bindable command) option to jump to one of the "Staged changes", "Unstaged changes", "HEAD" in the main view would be handy.

koutcher commented 2 months ago

There is already a default binding to jump to HEAD (H). There is no binding for Staged changes and Unstaged changes but they are generally located next to HEAD. If you really want a binding, you can add one to your .tigrc taking @ as an example.

andree182 commented 2 months ago

Right. But ATM there's nothing like the 'HEAD' ref for staged/unstaged, or is it? I see e.g. LINE_STAT_UNSTAGED in the code, but can't figure out anything that could be used as ":goto xyz".

Or you mean some hack with that "/^@@"? I don't see how to put anything like that into goto_id()...

koutcher commented 2 months ago

It's not a hack, :/Unstaged changes will look for lines containing the text Unstaged changes. You can't use goto, it requires a ref argument.

andree182 commented 2 months ago

Cool, that works, as does just simply '/Unstaged changes', any specific reason why use ':/...'?

Last thing, it seems that I'd need something like #1328 , to do the following

:/Unstaged changes ; :enter

but it seems that (if I'm looking at the right code) run_prompt_command() / exec_run_request() doesn't have a way to split the command and/or terminate the search string. E.g. something like:

:/Unstaged changes/ ; :enter

I'm just asking, it's probably just a minor usecase, so if it's not possible, no problem...

koutcher commented 2 months ago

Copy-paste from @, :/ is the original syntax. It is not possible to bind multiple commands at this time, the keybinding structure only references one request. Making it "multiple" might not be straightforward for the execution part.