I’m not a programmer but I do this on the Linux command line all the time to find a command I used days or weeks ago. Or I’ll spend 20 minutes grepping history instead. All to avoid spending 5 minutes reading the manpage so I can remember which flags and arguments I used.
Perhaps pressing [Ctrl]+[R] and typing to search makes it easier, I mean instead of grepping history?
Most terminal emulators support it.You can also change your query (backspacing and typing again) and press [Ctrl]+[R] multiple times to go to older matches.
I will have to try that, I didn’t know that functionality existed, thanks!
Let me tell you that you can also add comments to your terminal commands and use them to search history using fzf. This might sound confusing but basically you do this:
commandwithweirdoptions --option1=value1 --option2=value2 # run the usual thing
Then you press Ctrl+R and type anything like «the thing», it uses fuzzy matching and finds the command in history, with a menu of other similar commands. Press enter, done.
Note that you need to have fzf installed, otherwise there is no fuzzy matching and no menu of matching history results.
Seems to work with [Ctrl]+[R] as well, though of course only with exact matches.
Sure, just as I said, this would work id you don’t need menu or fuzzy matching. But I would recommend using fzf history search anyway, it’s just too good.
M-hm, I will try it as well! I was just letting people know the comment trick works regardless, cause that’s a nice tip as well!
I’ve never understood prompt decoration like this.
How.
Does.
Punctuating.
Every.
Statement.
Increase.
Readability.It makes my eyes bleed.
You meant the PS1 prompt?
I just use one of the default oh-my-zsh themes that makes a clear line, so I can easily find the last line above a long output, for example when trying to read it back chronologically. With other PS1’s I often scroll over it without noticing.
And then you realise your dumb endless ls-ing has pushed the command off the history list
This is too accurate!
Can you change the history list size?
Can you configure it to ignore ls and cd …
*tap*
no
*tap*
no
*tap*
noOkay, NOW it’s getting personal!
me typing “sudo !!” instead of rewriting the shell command undoes this.
Who is writing SQL in the terminal?
MariaDB CLI about once in a blue moon when I have to clear some table that’s gotten borked.
Was thinking the same thing… now, searching through all my SQL scripts for the past year to find the same logic I want to replicate in another script, well that’s different.
I save “template” SQL queries in a special directory so that I don’t have to google how to do specific things. It’s basically my own personal “examples” folder.
Me in the bash terminal