This question already has an answer here:
- Bash history search, partial + up-arrow 6 answers
It's normal when using terminals that pressing up and down cycles through previous commands entered chronologically.
I learned from a site how to add to that behaviour by autocompleting what I'm typing at the cursor based on previously entered commands when pressing up and down.
For example, let's say I typed the following commands in this order:
If I haven't typed anything, pressing up and down will cycle through all of the lines just like normal. But, if I've typed
ls, pressing up and down cycles through all commands where the first 2 characters are
ls (lines 1,2,3,4,6 above). Entering
ls (with a space after) though, will only let up and down cycle through lines 1,2,4,6. Similarly,
ls Vid lets the arrows cycle through lines 1,2,4 but
ls Videos just allows cycling between lines 1 and 4.
It's pretty useful to complete values specific to commands that you need to enter over and over again without having to cycle through every single unrelated command you've entered between them. For example, I'm trying to test the effects of
env values, like locale, on things:
env [many different values] [command] [insert many different commands here] env [slightly different values from before] [command] [doing other stuff]
I'd only have to press up a few times after typing
env to cycle between the values I've tried.
I apologize if it's a bit of a long way to describe it. I don't know what it's called. My terminals used to have this behaviour, but they seem to have lost it and I can't find the site I learned it from. I think it has something to do with editing