NimbUx wrote: ↑
Fri Feb 14, 2020 1:17 pm
Have been reviewing "man history" but couldn't find if there is some convenient way, like at a key-press, while scrolling back the Bash (or other compatible) history buffer, to *delete* the line currently shown - permanently removing it from the historic....
I'm reminded of JPsoftware's 4DOS and 4NT shells which had a comparable history mechanism, inspired, no doubt, from *x shells, and where "Ctrl-D" would delete the current item, but obviously that key cannot work similar under Linux.
Some notes on this:
1) "man history" is interesting, but that's primary of value to C programmers. Not much in there of a UI nature.
2) I am familiar with the 4DOS functionality to which you refer (it was nice), and I'm pretty sure bash doesn't have anything like that. Although, there's a *LOT* of text in "man bash" about the various keys that do various things (for both fans of Emacs and fans of vi). I'm in the vi camp, and I've learned and used many of these things, but feel like there's tons of things in there that I've never needed to learn. But I didn't see anything in there along the lines of interactively deleting history lines (in the manner you would like).
3) (This is the substantive part of this post) The focus in bash seems to be more on avoiding cluttering up the history list with junk in the first place. There is a shell variable HISTCONTROL that you might be interested in. I have long had HISTCONTROL set to "ignoreboth", but I have recently added "erasedups" to it. That seems to alleviate the main problem with the history list - which is it cluttering up with duplicate lines, as you execute the same stuff over and over.
Another thing that might be useful, but which I have not tried/tested yet, is using HISTIGNORE to ignore "short" commands. I have a general feeling that there's not much point in putting commands shorter than, say, 3 characters, into the history list. E.g., I have "j" aliased to "jobs -l" and I use this a lot, but it would be nice if that didn't waste a history list slot every time I use it.
I'm not sure what the "pattern" would be to match strings of length less than 3.
Anyway, hope this helps. Let me know if you figure anything else out.