Spyke

This is it, my first saved comment on lemmy

2
Doolbsreply
lemmy.world

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.

10
not_nenoreply
lemmy.world

Man I over use it at work - even when sitting in front of a pwsh prompt

4
frankreply
lemmy.world

Is there a MacOS versión of this? Asking for a friend.

5

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.

8
lemmy.world

Ctrl R > start typing

You're welcome to have your life changed

41

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'

4

Or the history substring search plugin for zsh showing inline history as you type, like fish.

1
lemmy.world

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.

36
vlemmy.net

Wait until they learn that you can ctrl+u when you mistyped your password in sudo instead of spamming backspace...

15
goodnessmereply
lemmy.world

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.

2

I end up hitting Ctrl+u at work all the time and then being disappointed and holding backspace.

2

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!

2
rambarooreply
lemmy.world

history | grep

Does the job well if the key combo doesn't work.

11

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.

1
0x4E4Freply
sh.itjust.works

Oh, and Ctrl + Shift + R brings you back in the search, niiiiice.

Thank you kind stranger 👍 ☺️.

5

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!

1
meitireply
lemmy.world

my humble method: history | grep -i searchterm

8

fzf is 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.)

2
lemmy.world

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.

11
0x4E4Freply
sh.itjust.works

fish automatically searches as you type, just start typing and press -> when you find the command you need.

2

Zsh does the same, though I think you need oh my zsh and a plugin for it.

2
lemmy.world
  1. vim ~/.inputrc
  2. Paste the following:

"\e[A": history-search-backward "\e[B": history-search-forward

Thank me later

11

Man, I've been on unix systems since, oh, 1994, but I've never messed with my .inputrc ... may need to take the dive....

4
overtinkerreply
lemmy.world

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!

1
lemmy.world

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

7

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).

1

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

2

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.

10

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.

8
lemm.ee

Fish finally broke me of this habit, and now it's one of the first things I install on any system

8

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.

3

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.

2

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

2

One of the top reasons I use fish is that I never learned how to cycle through the results of ctrl+r in bash

2
lemmy.world

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

6

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

2
lemmy.world

history | grep {some part of command}

Much more useful for going further back, even without grep.

5

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.

3
lemmy.world

cat .bash_history | grep keyword

But yeah pretty much.

4

You know you don't actually have to do cat 😂. But yeah, I know, I do it as well 🤣.

2
vlemmy.net

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.

5
vlemmy.net

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 (¬_¬)

1
lemmy.world

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).

2
vlemmy.net

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.

2

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.

2

Since this post triggered hidden gems: ^old^new will substitute old with new from the last command and execute.

3

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.

3

This speaks to me more so for SSH, which I guess is the same…. But yah.

3

no I don't want to write the single word command out again I'd rather go up the history with more keypresses

3

Easier to type history then !xx where xx is the number of record in history.

2

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.

1

I just type "history" to see the last like 20 things I typed in, chances are in that list.

1

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.

1

grep pattern $HISTFILE for greater flexibility.

And you can use `backticks` to format the text as inline code.

1