marlonrichert / zsh-hist

📝 Edit your Zsh history from the command line.
MIT License
148 stars 13 forks source link

Don't add current command to history (`ignore` flag) #21

Closed martin-braun closed 1 year ago

martin-braun commented 1 year ago

What do you want?

Running a command without it being added to the history in the first place (sort of, it shall be added, but removed instantly). This would be great, as it would allow to send a single command in incognito without the necessity to send a hist d -1 afterwards.

Why do you want this?

I have so send a secret to my Android phone via USB debugging (adb shell -n input text), because the TAN2GO app of my bank won't allow me to paste in passwords from my password manager. Flawed design. I then want to prevent the secret in my history.

Who else would benefit from this?

Anybody who wants to send a single command and delete it from history in one go, i.e. when having the command on the password manager like I do. Right now, sending adb shell -n input text mysecret; hist d -1 will not remove the secret, but the history entry prior. So the user has to send two commands.

How should it work?

Given this situation: A new flag to secretly send a command and remove it from history afterwards, let's call it ignore/i?

When I perform these steps: hist ignore echo secret

Then I expect this to happen: It should print secret without adding echo secret to the history.

Thanks!

marlonrichert commented 1 year ago

That's already possible in Zsh natively. You have three options for this, all of which can be combined:

martin-braun commented 1 year ago

@marlonrichert Thank you for the detailed explanation, it makes sense to do it this way. Very useful.