snipkit icon indicating copy to clipboard operation
snipkit copied to clipboard

Command should be inlined so it can be confirmed and stored in histfile.

Open seivan opened this issue 2 years ago • 6 comments

Going from snipkit exec to actually having the command executing has too many flows, and still doesn't put the command in the terminal input and history.

image image

Isn't it better to change so so the command is inlined into the terminal window and just requires to user to press enter. That way it gets stored in history and the redundant confirmations are removed. Pressing enter is the confirmation.

seivan avatar Nov 27 '23 07:11 seivan

Hi @seivan , I get your point - however, I think that this is a matter of preference.

I'm open to the idea of making that possible via a setting option. Maybe I have time to implement this during the upcoming holidays...

lemoony avatar Dec 05 '23 07:12 lemoony

Just a quick update: We are going to introduce a new command for that - instead of exec something like inline

lemoony avatar Jan 09 '24 10:01 lemoony

@lemoony What's the status of inline? Honestly the confirmation concept is silly. Just output it into the prompt and let the the confirmation. It seems like with inline and execConfirm there would have to be two confirmations.

Just make execConfirm output the command into the terminal, and let the user confirm by enter And with execConfirm: false, just execute it directly.

seivan avatar Jul 09 '24 04:07 seivan

For instance, for ZSH prepending print -z before the script it will make sure its on the prompt. https://github.com/lemoony/snipkit/blob/c1de048bbaead8c0d124a7dc6f83b8c7b2f97000/internal/app/app_exec.go#L47

seivan avatar Jul 09 '24 04:07 seivan

Hi @seivan , sorry it takes so long but I'm a bit swamped with work. My current plan is to make the next SnipKit release some time near the end of August.

As I said, I will introduce a new command for that. I like the way things currently are... that's just a matter of preference. But that shouldn't affect you - you just have to use a different sub-command then.

lemoony avatar Jul 10 '24 11:07 lemoony

After investigating this feature request, I've found that it's not possible to inline commands directly into the current shell prompt. The print -z command, supported by ZSH, seems to be the only viable solution for this.

I adjusted the code to ensure the snipkit print command works in subshells. Pull request #256 includes a small documentation section on how to set up SnipKit to allow direct inlining of commands. Unfortunately, this approach only works with ZSH.

Due to this limitation, I've added an additional copy command (#257) that copies the command to the clipboard (something I've been meaning to add for a while now).

Both additions will be included in the next release (some time soon).

lemoony avatar Aug 12 '24 16:08 lemoony