lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Custom commands prompt type with multiline support

Open Djedouas opened this issue 10 months ago • 10 comments

Hi,

I would like to adapt the custom command with conventional commit templates to add a step for writing a multiline description.

To do this, I am looking for a prompt type that could be used to input text on more than one line, like we have when committing (i.e. the prompt below the commit title).

image

Thanks

Djedouas avatar Apr 05 '24 14:04 Djedouas

Are you thinking about the Custom command popup when you press : or the predefined custom commands you have in your config.yml?

Predefined custom commands do support multiple lines, you just need to write them like this (>-):

- key: 'D'
  command: >-
    echo "line1" &&
    echo "line2"
  context: 'localBranches'
  stream: true

I don't think we document it anywhere, though :thinking:

mark2185 avatar Apr 09 '24 07:04 mark2185

Thanks for your answer :)

This is useful to know, but I think I might have been misunderstood...

I am talking about the predefined custom commands I can configure in config.yaml. At least I need to pop up a prompt in which the user can write multiple lines of text. Ideally, I need to pop up a prompt exactly like the standard commit prompt which is in two parts (a one-line box, and a multi -line box below), and getting the text as a result keys from this prompt.

Djedouas avatar Apr 09 '24 08:04 Djedouas

Ah, now I get it.

Currently we don't have something like that, but (at a glance) it shouldn't be too difficult to implement.

Would you maybe be willing to investigate this? (you can say no :) )

mark2185 avatar Apr 09 '24 08:04 mark2185

cool :)

I have to say no, learning go is not checked on my wish list yet... ;-)

Overall I think that a generic prompt supporting multi-line text could be more suitable as a custom command prompt type, rather than a mixed one-line / multi-line prompt which is more specific.

Djedouas avatar Apr 09 '24 08:04 Djedouas

Overall I think that a generic prompt supporting multi-line text could be more suitable as a custom command prompt type, rather than a mixed one-line / multi-line prompt which is more specific.

Agreed, but the benefit of the mixed one is the confirmation vs newline problem is solved. We use Enter for both, but when in the single-line prompt it means "Confirm", while in the mult-line prompt it means \n. If we had only the multiline, then we'd have to figure out how to actually confirm the input or how to add newlines and sacrifice some other key.

mark2185 avatar Apr 09 '24 08:04 mark2185

Ah yes right! 😄

And I must say that it's a very good mechanism, it was very intuitive for me the first time I used it.

Djedouas avatar Apr 09 '24 08:04 Djedouas

Hi, I created PR for a multiline supported prompt and named it textbox Please review this. Thank you 😄

yongjoon-km avatar May 05 '24 04:05 yongjoon-km

Thanks @yongjoon-km , it works :)

Regarding @mark2185 comment, I see you chose <a-enter> as a key combination to confirm the multi-line textbox.

Works great for me, but could it be a problem if the combination is already associated somewhere in lazygit or system wide?

Djedouas avatar May 13 '24 09:05 Djedouas

Thanks @yongjoon-km , it works :)

Regarding @mark2185 comment, I see you chose <a-enter> as a key combination to confirm the multi-line textbox.

Works great for me, but could it be a problem if the combination is already associated somewhere in lazygit or system wide?

Hi @Djedouas, I chose confirmInEditor keybinding in lazygit which is default <a-enter>. If <a-enter> is being used in system wide, user should map another key as confirmInEditor. Note that this keybinding is also used in the commit description prompt. Or <a-enter> might be used by another keybinding in lazygit, then proper keybinding must be set for confirmInEditor keybinding. Also, the description of textbox prompt on the top right corner is applied by keybinding's key name.

yongjoon-km avatar May 13 '24 11:05 yongjoon-km

Great that sounds perfect 😃

Djedouas avatar May 13 '24 13:05 Djedouas