BuilderIO / ai-shell

A CLI that converts natural language to shell commands.
MIT License
4.21k stars 278 forks source link

Ability to save and load command #39

Open AlaEddineBoughanmmi opened 1 year ago

AlaEddineBoughanmmi commented 1 year ago

would be nice to Allow users to save command for later use or load them from a file.

steve8708 commented 1 year ago

Oh that’s interesting, what’s the use case you have in mind for this?

On Tue, Apr 11 2023 at 8:39 PM, aeb < @.*** > wrote:

would be nice to Allow users to save command for later use or load them from a file.

— Reply to this email directly, view it on GitHub ( https://github.com/BuilderIO/ai-shell/issues/39 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AAGOEA7PN5YQVVJCPQRCJNLXAYPVNANCNFSM6AAAAAAW3DACUQ ). You are receiving this because you are subscribed to this thread. Message ID: <BuilderIO/ai-shell/issues/39 @ github. com>

AlaEddineBoughanmmi commented 1 year ago

Offline use: having the ability to save and load command can be useful in situations where you may not have access to the internet, as you can still use the commands you have saved.

It can also be helpful if you already did multiple revise for a command before arriving at the desired result, as you can save the command instead of having to repeatedly ask the ai-shell tool for it.Additionally

If you choose not to run a command it will not be stored in the history of your terminal, or if your system is configured to not save command history (i.e. if the HISTSIZE value is set to 0)... having an option to save the result would be a plus for users.

Norfeldt commented 1 year ago

@steve8708 how about making it so that the executed commands by ai shell is put into the terminal history?

I'm a heavy user of the up arrow to reuse commands and miss this feature.

It's an awesome tool btw - thx a lot for building and maintaining it 🤘

AlaEddineBoughanmmi commented 1 year ago

@Norfeldt good point.

The command runs in a subshell not the main shell that's why it not saved in the history.

a solution for this would be to execute

exec(`history -s "${script}"`);

after running the actual script.

That works for linux and we need a solution for windows too.

Norfeldt commented 1 year ago

@AlaEddineBoughanmmi I would suggest running it before executing the script instead of after.

It's a shame that windows block this feature 😥

Edo78 commented 1 year ago

Not having commands in the history is actually the only issue I have with this tool. Can we have this feature at least as an option?

steve8708 commented 1 year ago

Definitely interested in contributions for this. Would love if we can save in the actual history so hitting the up arrow works, but open to workarounds too

Edo78 commented 1 year ago

I just realized how useful could be to have the prompt and the command saved so that upon checking on the output we can iterate to perfect the command. For example a provided command can rely on calling an API and parsing its output but I as a user can have no knowledge about the response schema so I have to blindly accept the suggested command only to see it failing. Having the possibility to provide a feedback or an error to chatgpt can help it understand its error and improve a complex command.

AlaEddineBoughanmmi commented 1 year ago

I'm interested in a PR. The default should be to save in shell history and it can be toggled on or off.

AlaEddineBoughanmmi commented 1 year ago

@Edo78 with chat mode ai chat you can achieve your desired output (through iterations) the only limitation for now is that ai-shell does not support multiline input so you can't provide it with the full error message 🙁 (the feature for a multi line prompt is requested and we will add support for it once it's complete)

Rafaelcv7 commented 1 year ago

Definitely interested in contributions for this. Would love if we can save in the actual history so hitting the up arrow works, but open to workarounds too

I have an implementation of this feature in development, at the moment it saves the command and let you load later with a "load" command. I'm working on adding the ability for the command to be shown in the history.

The idea is for the user to have his own saved commands and also for every command to be added to the history when executed.

But to be honest Zelda: Tears of the Kingdom has been eating my programming time away XD! Sorry