fish-shell icon indicating copy to clipboard operation
fish-shell copied to clipboard

history pager: delete selected history entry with Shift-Delete

Open krobelus opened this issue 2 years ago • 1 comments
trafficstars

After accidentally running a command that includes a pasted password, I want to delete command from history. Today we need to recall or type (part of) that command and type "history delete". Let's maybe add a shortcut to do this from the history pager.

The current shortcut is Shift+Delete. I don't think that's very discoverable, maybe we should use Delete instead (but only if the cursor is at the end of the commandline, otherwise delete a char).

Closes #9454

krobelus avatar Jan 29 '23 17:01 krobelus

This seems like a good idea. My question is if we could make the bind function more general and have it delete the current commandline if the pager isn't open?

I don't think that's very discoverable, maybe we should use Delete instead

I'm kind of wary of adding something permanent like this to a very simple key press that you might just use to edit. So I think I'd prefer shift-delete for now.

faho avatar Feb 01 '23 11:02 faho

shift-delete matches the behavior of native Windows autocomplete inputs w/ history enabled, which was later adopted by Chrom(e|ium) and, I think, Firefox. I'm not comfortable with a plain delete binding, either.

mqudsi avatar Feb 15 '23 22:02 mqudsi

sounds good, let's stick to Shift+Delete

My question is if we could make the bind function more general and have it delete the current commandline if the pager isn't open?

Yeah we should make it work at least during an up-arrow search (where Shift+Delete shall switch to the next older match). If no search is active, it should maybe show an interactive prompt for selecting commands to delete, based on the current commandline. That's me spitballing, leaving this case for later.

There's a bug left, deletion does not work for space-prefixed commands. No big deal but would be nice to fix.

krobelus avatar Feb 21 '23 17:02 krobelus

Are you happy to merge this for now without that fix?

zanchey avatar Jul 04 '23 14:07 zanchey

yeah; actually I can't reproduce the problem with space-prefixed ("ephemeral") commands anymore. Looks like we only ever keep one of them in memory, for simplicity of implementation.

krobelus avatar Jul 04 '23 16:07 krobelus

After #2110 has been resolved I was looking into this, but I'm not sure if i get this right:

Shift+Del should delete a whole history entry if the cursor is at EOL, right? If i du an Arrow+Up navigation and press Shift+Del it only deletes the last character, but not the line.

Anything I'm missing @krobelus ?

~~Update: I just saw [redacted] which mentions something about Shift+Del not working for file-written history entries. But I just stumbled over this issue with a command entered seconds prior. I'm confused.~~ Wrong project.

bentolor avatar Feb 16 '24 16:02 bentolor

Shift+Del should delete a whole history entry if the cursor is at EOL, right?

No.

It should delete the history entry you are selecting in the history pager, the thing you start with ctrl-r.

We've decided not to do it in the commandline for now.

faho avatar Feb 16 '24 17:02 faho

I still think we should try to make it work in the commandline but it's not clear to me what the UI should look like. Echoing the deleted command is a possibility but isn't it a bit un-fishy? Not sure

krobelus avatar Feb 16 '24 17:02 krobelus

Thanks for clarifying, @faho and @krobelus !

bentolor avatar Feb 16 '24 17:02 bentolor