-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Interactively delete history entries during auto-completion (i.e. via Alt-Del) #2110
Comments
That's a good idea! |
The "current completion proposal" is not added to the interactive command history. You have to actually execute a command for it to be added to the history. By that time it's far too late for a key binding to have any effect. @bentolor Can you provide more details about your scenario? Perhaps by creating a asciinema recording? |
@krader1961 Why would the item need to be added to history again? |
I think maybe there is a misunderstanding with what he's asking for - the "proposal" I think he's referring to is the completion (edit: probably the autosuggestion you'd see) fish is proposing that the user would be rejecting, as I read it. |
So I suspect he's wanting to be able to hit alt-del to nuke what he sees suggested from history, or while searching history (with the up arrow), remove the current entry from history. It'd essentially cause a The interactive deletion is important because the desired (undesired) history item may not be the first result due to the context-sensitive nature of autosuggestions and the builtin's inability to do queries on those variables. Deleting the up-arrow stuff and deleting a autosuggestion after accepting it with the right arrow key, could obviously be hacked in today because you have the full result of the completion and the accepted autosuggestion in the buffer to search with (after they activate it). |
You nailed it!
|
This is a cool idea. We could even do it without confirmation - just have to report the command we deleted, so the user can copy and paste it if they want to reinstate it. |
Okay, that makes sense. In retrospect I should have grokked that from the original comment. And this is the first really good example I've seen for why fish should continue to have a way to delete individual history entries. Now we just need to make that mechanism robust. There are also some details to be worked out with regard to this proposal. For example, should the current command line be cleared? Should we also bind [alt-backspace]? P.S., [ctrl-del] can't be done because [del] is already a control character. It's as if you tried to |
Thought about this, too. On the plus side, this could make sense, because otherwise the user needs to switch to a different key-combination to clear the line after his cleanup. On the negative side this could suprise the user, as the semantic of the key combination changes on the last history match. So I'd say "no" and would be fine with the case that after typing
For me [Backspace] is clearly bound to editing the line I'm on and currently seems to act as "delete last word" which IMHO is perfectly appropriate. So would leave [alt-backspace] untouched.
[alt-del] sounds fine and as the most intuitive option to me. |
Another use-case I have is that I'm still unable to remember if it is After doing it wrong only one time the fish history deceives and annoys me so much, that I start to edit the history over and over again. As I still cannot tell you which one of the both word git is expecting, this game will be ongoing for me for an indefinite time ;-) |
Maybe we should record the exit code in history? Note: this is probably tricky - we'd need to go back and alter the record after the job completes. |
@floam Interesting idea. But many user errors will not cause an exit code indicating it. Others might return exit codes because the operation failed, but not the command syntax (i.e. So I still think the feature to easily heal/delete completions would offer the biggest "bang" for the "bucks". |
@bentolor Is the following function what you want?
This has the problem that when deleting the last match, history-search-backward has no effect, so there's no visual indication of the delete operation. BTW, how to bind ALT-DEL? |
|
I added the following code to my
Currently testing. But so far it looks pretty good, @jinliu ! Thanks. |
@jinliu If you delete the last history element, nothing visible happens. The command is erased from history, though. This might be confusing for the user. Probably the best solution in this case would be, to revert to the characters the user originally entered (and which are highlighted on history search matches) |
Agree. But I guess this (and deleting autosuggestion history matches) must be done in C code. |
Since fish v3.0 the proposed script no longer works :-( : Even if the expression results only in one matching entry,
|
Try |
Thanks, this improves the situation. Unfortunately but no longer to the full beauty it IMHO previously did: After pressing It's deleted from history, though: After pressing |
This was wrong - we do not add the item to history until after the command completes. So it would not be difficult to store the exit status in history. However the exit status of an arbitrary command may indicate a failure: we would need to tell fish about commands where that actually is the case - with |
This scenario immediately came into my mind. I think this is a very common pattern In those cases: After your adjustment was successful, you really want to drop the other command, because it will now continues to deceive and confront you with the same error over and over again.
Doe fish auto-purge/expire history entries? Nevertheless, storing the exit code of commands and offering a „delete all failed commands from history“ sounds great to me. |
This is handled by #9515, which allows it in the history pager, where it's clearer that there's a history context. |
Fish auto-completion is great, but the history can be easily bloated with wrong & unwanted entries
I'm aware about
history --contains keyword --delete
and the interactive history editor viafish_config
but find them rather cumbersome.It would be great to have i.e. a key combination like
[Alt-Del]
or[Ctrl-Del]
to remove the current completion proposal from the historyThe text was updated successfully, but these errors were encountered: