If you enjoy that, then let me introduce you you fzf - a fuzzy finder that has support for replacing ctrl + r in shells with fuzzy matching. Among other uses.
It's the same, ctrl + r. It is a bash/shell thing so works on any os that uses bash or similar shells. Note, it is not the command key, but ctrl, unlike a lot of other shortcuts on macos.
For real. Alternatively use alias to reassign a command to something shorter if it's one you're always searching for later. I use 'update' as an alias for 'apt update && apt upgrade -y && apt autoremove && apt autoclean'
Y'all know about ctrl-r to search history, right? I went for so many years without even thinking to look for something better than up-arrow, so I have to mention it.
It deletes all keystrokes that have been entered. So, if you know you made a typo when entering your password, you don't have to press backspace many times to make sure you have deleted all the characters before starting over but you can just press ctrl+u and start over.
Here's another mindfuck: gnu readline is so popular that developers of other software tend to implement its keybinds as hidden features/eastereggs. That's why ctrl+u works in GTK text input boxes as well!
Good tip!I didn't know about that. I just tried it out and it works pretty well but I worry how long it will take to break the habit of mashing the up arrow all the time since I've been doing it so long. This is clearly better though.
Hey! Sorry just getting into Linux, I love learning about cool ways of doing things more efficiently. What does this do exactly? I've noticed others mentioning CTRL+R and I am not sure what that means either. Thank you!
Basically, while ctrl+r is nice, this is how I got used to use my system. What this does is enable search for when you press arrow up. If you type nothing then it’s default behavior but if you type “ssh” and then start pressing arrow up it will bring up the previous command that had the word ssh in. It’s worth it for someone who constantly forgets ctrl+r exists
yeah, the other day i was supposed to remove a restriction from a router that was some custom thing built on a raspberry pi. i logged in, started messing around, trying to figure out the system, and of course i looked at bash_history because why not, i'm unfamiliar with the setup so it seemed like a good place to start. up until i found some commands editing it. so i'm like
$ export HISTFILE=/dev/null # alright, two can play this game
it ended up being a simply cron job that runs a script that starts and stops hostapd every once in a while. i didn't disable the cron job, i just commented out a critical line from the stop script. happy debugging to the sysadmin, lol
I feel this in my soul. Or when you realize you're hitting up up up up to find something trivial like ls and it would have been more efficient to just type ls. LOL.
Friendly Interactive SHell. I also use it, and I find some of the extra features delightful. I don't think it's POSIX compliant if you're one of the two dozen people who have to worry about that for your use case.
You know how we have the bash shell by default on most Linux systems? Well there's also the fish shell you can probably find it in your repo and try it out.
Fish Shell - Friendly Interactive Shell. It has tons of themes and customizable prompts, but most importantly it scans through your command history and autocompletes previous commands. You can even to back through previous versions of a certain command for example I copy a couple different files a lot so I'll type 'cd' then press up to get to the specific command I need. It'll also autocomplete command names if they're in the path. It's a life changer for sure
As some one who SSH's from a phone to run Docker containers and will be moving the container volumes to a different location, I thank you for this lovely command.
y... you do realise this is a meme, right? If you want to find a specific command that you ran in the past, you can just hit ctrl-r and search for it? No-one is actually spamming the up key, it's a joke.
What keyboard do u have btw? I recently built myself an ex-dactyl, and I absolutely loved it. The split layout actually lets my wrists be completely straight and relaxed, and the outward angle is preventing the wrist bones from crossing too much. It broke down a while ago tho, and I haven't had the motivation to fix it tho, so back to bog-standard ANSI layout for now (¬_¬)
Oh damn u got the kinesis advantage!! I don't own one personally, but I had a chance to type on one at a keyboard store. Absolutely loved it. It felt pretty much the same as my ex-dactyl, apart from a different layout around the thumb clusters. It also took me a while to get used to the weird layout (especially considering that I never learned to touch type lol. On a standard keyboard, I pretty much just peck-type very fast), but once I got up to speed, it felt wonderful. I think I would prefer my ex-dactyl to the Advantage tho, simply because it is two separate pieces. Not that it offers a huge ergonomic boost or anything, I just like having the extra desk space in the middle to put my coffee on (/¯–‿・)/¯ .
By the way, you can edit comments on lemmy, no need to reply twice. It's under the meatball menu next to the reply button.
If you like the kinesis, but want separate pieces check out the Ergodox EZ https://ergodox-ez.com/. It's another ortholinear keyboard, but I couldn't get used to the tenting.
I spend every day in a terminal, vim is my go to text editor lol. I can’t even imagine.
Also, I have RSI and I invested in a good keyboard. It literally saved my wrists. Just saying, if you need it to pay the bills, invest in a good keyboard.
I'm more of a tcsh user, where by default alt+p will search backwards for a command that starts with the text currently written in the prompt. So, type "vim" followed by alt+p as many times as necessary until I find the exact vim call that I'm looking for (normally followed by an alt+n because I pressed one too many times on p). In bash by default you have ctrl+r followed by the string you're looking for and press ctrl+r until you find the command. I can see online that alt+p is bound by default to non-incremental-reverse-search-history, where I think history-search-backward would be a better match to tcsh's behavior. Currently not at the computer so I can't test it.
I’ve been using unix for about 20 years (Oracle DBA) and am embarrassed about how few shortcuts I know.
I vaguely remember seeing someone use tab to auto fill a command but never remember to find out how.
ctrl + rgangYou can also install https://github.com/dvorka/hstr to supercharge your
ctrl+rI can recommend fzf since it also supports searching the current directory
This is it, my first saved comment on lemmy
Holy Crap. I have gotten into the arrow up mode. Then I went to History.
But, but, but ctrl + r. Holy crap.
Thank you kind sir or madam.
If you enjoy that, then let me introduce you you fzf - a fuzzy finder that has support for replacing ctrl + r in shells with fuzzy matching. Among other uses.
https://github.com/junegunn/fzf#key-bindings-for-command-line
Thank you very much.
Man I over use it at work - even when sitting in front of a pwsh prompt
pwsh with nushell is pretty good
Is there a MacOS versión of this? Asking for a friend.
It's the same,
ctrl+r. It is a bash/shell thing so works on any os that uses bash or similar shells. Note, it is not the command key, but ctrl, unlike a lot of other shortcuts on macos.Fish gang arise (no need for ctrl+r, just press up)
And with a fantastic approximation of fzf history searching.
Ctrl R > start typing
You're welcome to have your life changed
What the actual.... Thanks
Bruh. Ctrl-r
For real. Alternatively use alias to reassign a command to something shorter if it's one you're always searching for later. I use 'update' as an alias for 'apt update && apt upgrade -y && apt autoremove && apt autoclean'
you're amazing, this is going to change how I use fish
Very handy, thank you.
Or the history substring search plugin for zsh showing inline history as you type, like fish.
Y'all know about ctrl-r to search history, right? I went for so many years without even thinking to look for something better than up-arrow, so I have to mention it.
Wait until they learn that you can
ctrl+uwhen you mistyped your password insudoinstead of spamming backspace...What does that do?
Delete until start of line. So essentially equivalent to spamming backspace a bunch.
It deletes all keystrokes that have been entered. So, if you know you made a typo when entering your password, you don't have to press backspace many times to make sure you have deleted all the characters before starting over but you can just press ctrl+u and start over.
ah neat, thanks.
I end up hitting Ctrl+u at work all the time and then being disappointed and holding backspace.
Bro. You just changed my life and don't even realize it
Here's another mindfuck: gnu readline is so popular that developers of other software tend to implement its keybinds as hidden features/eastereggs. That's why ctrl+u works in GTK text input boxes as well!
Damn, that really does solve a lot of problems, lol 😂.
history | grep
Does the job well if the key combo doesn't work.
Followed by !xxx where xxx is the number of the command to re-run
This. I didn't know about CTRL+R, but this has been my goto
Good tip!I didn't know about that. I just tried it out and it works pretty well but I worry how long it will take to break the habit of mashing the up arrow all the time since I've been doing it so long. This is clearly better though.
Finally the
lscommand!Time to up your game with Ctrl + R reverse search! 🤓
Oh, and Ctrl + Shift + R brings you back in the search, niiiiice.
Thank you kind stranger 👍 ☺️.
Look up fzf for luxury treatment
Holy hell this is the best thing since tab autocompletion
And the command is something like
ls -l👍I see you and I had the same idea. Ha!
I usually use
ls -hal.ls -lahis what I do 🙌ls -lah unite
Up up up up up up up up up oh wait down
you allllways overshoot
Based
ctrl + r then enter phrase
With fzf!
I haven't been on linux in a while but i remember using a file manager that had fuzzy finder and it was nice. I miss linux actually. oh well!
Ctrl+R together with
fzfmakes this obsoletemy humble method: history | grep -i searchterm
Then ![historynumber] to execute it
exactly!
fzfis pretty cool, but I found its ctrl-r "menu" to be more confusing than the old "one entry at a time" style.(Ofc could be a configuration thing but I'm somewhat an oldhat when it comes to my terminal habits.)
I usually do ctrl+r but with zsh I can type the beginning of the command and press up and it will search that way too.
fish automatically searches as you type, just start typing and press -> when you find the command you need.
Zsh does the same, though I think you need oh my zsh and a plugin for it.
"\e[A": history-search-backward "\e[B": history-search-forwardThank me later
Man, I've been on unix systems since, oh, 1994, but I've never messed with my .inputrc ... may need to take the dive....
Hey! Sorry just getting into Linux, I love learning about cool ways of doing things more efficiently. What does this do exactly? I've noticed others mentioning CTRL+R and I am not sure what that means either. Thank you!
Basically, while ctrl+r is nice, this is how I got used to use my system. What this does is enable search for when you press arrow up. If you type nothing then it’s default behavior but if you type “ssh” and then start pressing arrow up it will bring up the previous command that had the word ssh in. It’s worth it for someone who constantly forgets ctrl+r exists
That's awesome. Thanks for explaining!
Ok this is actually great. Is there a way to make it so when you down arrow again it will clear the cmd line (or take it back to the prefix)?
Like "py" -> up -> down -> result is "py"
Currently it would show my last python command (or whatever matches).
I'll be a madlad and thank you right here, right now!
~/.bash_history is where my documentation lives
yeah, the other day i was supposed to remove a restriction from a router that was some custom thing built on a raspberry pi. i logged in, started messing around, trying to figure out the system, and of course i looked at bash_history because why not, i'm unfamiliar with the setup so it seemed like a good place to start. up until i found some commands editing it. so i'm like
it ended up being a simply cron job that runs a script that starts and stops hostapd every once in a while. i didn't disable the cron job, i just commented out a critical line from the stop script. happy debugging to the sysadmin, lol
I feel this in my soul. Or when you realize you're hitting up up up up to find something trivial like
lsand it would have been more efficient to just typels. LOL.$ ls -lals -halls -halalOnly had to scroll 15 time to find it.
Bro, do you even
^R?cat /var/www/vhosts.d/l[tab]o[tab]l[tab]a[tab]...
lola 🤨?
cat /var/www/vhosts.d/lolanotherfilehasthesamenamebutwith1.conf
Oh 🤣🤣🤣
ctrl+p gang RISE UP
No, no, no. You don't just land on the right one. You accidentally go past it and then have to press down once or twice.
Fish finally broke me of this habit, and now it's one of the first things I install on any system
Yep, me as well ☺️.
Goodbye reddit and thanks for the fish.
another happy fish convert here too!
Fish? Please enlighten a casual user
Friendly Interactive SHell. I also use it, and I find some of the extra features delightful. I don't think it's POSIX compliant if you're one of the two dozen people who have to worry about that for your use case.
You know how we have the bash shell by default on most Linux systems? Well there's also the fish shell you can probably find it in your repo and try it out.
Fish Shell - Friendly Interactive Shell. It has tons of themes and customizable prompts, but most importantly it scans through your command history and autocompletes previous commands. You can even to back through previous versions of a certain command for example I copy a couple different files a lot so I'll type 'cd' then press up to get to the specific command I need. It'll also autocomplete command names if they're in the path. It's a life changer for sure
One of the top reasons I use fish is that I never learned how to cycle through the results of ctrl+r in bash
history | grep term
I have my zsh set up so that I can type in something and press up to search for commands I ran with the the things I typed
MX Linux does the same with bash
MX Linux does the same with bash
The command is ls
Woah. Quality of meme in this site amazes me.
It's more or less like on reddit, but less users.
*fewer
It's more or fewer like on Reddit, but with less users.
Control+r.
You're welcome.
Or
history | grep {command}i have a alias for h which is history, then hg which does this and i can search my whole 52 thousand line history file and find anything i've ran
I've just signed up to this site and I'm being personally attacked already. smh
Ctrl-R
history | grep {some part of command}
Much more useful for going further back, even without grep.
As some one who SSH's from a phone to run Docker containers and will be moving the container volumes to a different location, I thank you for this lovely command.
ah there's my password...
Guilty. Even knowing better ways laziness wins. Skyrim console too.
cat .bash_history | grep keyword
But yeah pretty much.
You know you don't actually have to do cat 😂. But yeah, I know, I do it as well 🤣.
Yeah, I grep on history and then ! to execute the line I want
y... you do realise this is a meme, right? If you want to find a specific command that you ran in the past, you can just hit ctrl-r and search for it? No-one is actually spamming the up key, it's a joke.
What keyboard do u have btw? I recently built myself an ex-dactyl, and I absolutely loved it. The split layout actually lets my wrists be completely straight and relaxed, and the outward angle is preventing the wrist bones from crossing too much. It broke down a while ago tho, and I haven't had the motivation to fix it tho, so back to bog-standard ANSI layout for now (¬_¬)
I use a https://kinesis-ergo.com/keyboards/advantage2-keyboard/. It took about 2 weeks to get the hang of it, but I'll never use another one!
Sorry, I just looked at your image again and see it’s the same setup lol. You’ll love this keyboard (no I don’t work for them).
Oh damn u got the kinesis advantage!! I don't own one personally, but I had a chance to type on one at a keyboard store. Absolutely loved it. It felt pretty much the same as my ex-dactyl, apart from a different layout around the thumb clusters. It also took me a while to get used to the weird layout (especially considering that I never learned to touch type lol. On a standard keyboard, I pretty much just peck-type very fast), but once I got up to speed, it felt wonderful. I think I would prefer my ex-dactyl to the Advantage tho, simply because it is two separate pieces. Not that it offers a huge ergonomic boost or anything, I just like having the extra desk space in the middle to put my coffee on (/¯–‿・)/¯ .
By the way, you can edit comments on lemmy, no need to reply twice. It's under the meatball menu next to the reply button.
If you like the kinesis, but want separate pieces check out the Ergodox EZ https://ergodox-ez.com/. It's another ortholinear keyboard, but I couldn't get used to the tenting.
I spend every day in a terminal, vim is my go to text editor lol. I can’t even imagine.
Also, I have RSI and I invested in a good keyboard. It literally saved my wrists. Just saying, if you need it to pay the bills, invest in a good keyboard.
Me when configuring a switch.
esc + kfor me! (vi for life)Since this post triggered hidden gems:
^old^newwill substituteoldwithnewfrom the last command and execute.I'm not proud to admit how long I spent as a SysAdmin before starting to use ctrl+r and just typing a search term.
This speaks to me more so for SSH, which I guess is the same…. But yah.
no I don't want to write the single word command out again I'd rather go up the history with more keypresses
Easier to type
historythen!xxwhere xx is the number of record in history.i'm in this photo and i love it
I'm more of a tcsh user, where by default alt+p will search backwards for a command that starts with the text currently written in the prompt. So, type "vim" followed by alt+p as many times as necessary until I find the exact vim call that I'm looking for (normally followed by an alt+n because I pressed one too many times on p). In bash by default you have ctrl+r followed by the string you're looking for and press ctrl+r until you find the command. I can see online that alt+p is bound by default to non-incremental-reverse-search-history, where I think history-search-backward would be a better match to tcsh's behavior. Currently not at the computer so I can't test it.
I just type "history" to see the last like 20 things I typed in, chances are in that list.
I’ve been using unix for about 20 years (Oracle DBA) and am embarrassed about how few shortcuts I know. I vaguely remember seeing someone use tab to auto fill a command but never remember to find out how.
I’m more of a ‘history | grep ’ sort of person
grep pattern $HISTFILEfor greater flexibility.And you can use `backticks` to format the text as inline code.
macOS terminal users too