jonas / tig

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

Support grabbing input from read #1319

Closed MarcCoquand closed 7 months ago

MarcCoquand commented 7 months ago

Heya!

I'm trying to add a command to allow creating a new file, mv files etc. directly from the tree view.

The approach I wanted to take was to use read, so I could create a command like :!read | xargs -I {} touch %(folder)/{}, however it seems that the read command does not work with tig, as it does not accept any input.

Would it be possible to support it? Then we could add all kinds of custom commands, it'd be incredible.

Maybe I am doing something wrong, and it is supported (afterall it can open an editor where I can give input).

MarcCoquand commented 7 months ago

Reading the docs more thoroughly, I was able to figure out how it is done!

Very straight forward

bind tree C >sh -c "echo 'Enter file name:'; read line; touch %(directory)/$line"

The > exits tig and reopens it upon completion.