-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add executeCommand Prompt #4183
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
@marakalwa could you explain the use-case behind this PR? |
Hmm I was looking at a way to get the result of a command into an input initialValue, would this somehow allow that since initialValue could be |
Oh my, I did not want to create a pull request for this PR yet. Must have done that very sleepy, either very early or very late 😅
This is exactly the use case for this PR. Running a command without user interaction and saving the result for use in further inputs is imo absolutely vital for building powerful custom commands. I will just use the relevant part of the customCommand that led me to create this change:
As you can see I used an excecuteCommand prompt here to format the UnixTimeStamp of the SelectedLocalCommit in such a way that it is human readable/editable (and can later be read by git in the 'command' part). Without executeCommand this would (afaik) be impossible in this form and require at least two custom commands and the use of the clipboard to get anything close to this. I have been running lazygit with this change for over a month with various customCommands using multiple executeCommand prompts without issue. I will try to now finish this PR asap. Lmk if you think I did something wrong here :) and thank you for this awesome tool @jesseduffield |
Okay that makes sense, sounds reasonable. I'll review the code once you've completed the PR |
Only stumbled upon this just now, I haven't been paying attention before. Isn't the solution of adding an executeCommand prompt type an unnecessary indirection? We now have #4438 which adds a "runCommand" function to be used in any template, isn't that more flexible? It has the downside that you need to run the same command twice if you want to have it both in title and in initialValue, but apart from that it seems clearer and easier to me. @marakalwa @jwickers Please have a look if this would fit your needs. |
@marakalwa @jwickers #4438 has been merged to master. Can we close this? |
If one can persist values with this new option, then this would indeed be no longer necessary. Are you aware if there is some sort of sandboxing/new shell between running terminal commands? |
No, there's no way to persist values, or communicate between commands. In the example above, if you want to use the result of a command twice (in title and in initialValue) you'll have to run the command twice. It's a bit of duplication, but doesn't seem too bad to me. Can you think of examples where this wouldn't be possible? |
PR Description
Please check if the PR fulfills these requirements
go generate ./...
)