• RomanRoy
    link
    fedilink
    arrow-up
    41
    ·
    2 years ago

    Ctrl R > start typing

    You’re welcome to have your life changed

    • PlasticExistence
      link
      fedilink
      arrow-up
      4
      ·
      2 years ago

      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’

    • 2ez
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

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

  • atx_aquarian
    link
    fedilink
    arrow-up
    36
    ·
    2 years ago

    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.

        • goodnessme
          link
          fedilink
          arrow-up
          2
          ·
          2 years ago

          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.

      • Jamie@jamie.moe
        link
        fedilink
        arrow-up
        2
        ·
        2 years ago

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

        • amanwithausername@vlemmy.net
          link
          fedilink
          arrow-up
          2
          ·
          2 years ago

          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!

    • rambaroo
      link
      fedilink
      arrow-up
      11
      ·
      2 years ago

      history | grep <search term>

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

      • BoofStroke
        link
        fedilink
        arrow-up
        6
        ·
        2 years ago

        Followed by !xxx where xxx is the number of the command to re-run

    • TrinityTek
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      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.

      • Joe B
        link
        fedilink
        arrow-up
        1
        ·
        2 years ago

        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!

    • meiti
      link
      fedilink
      English
      arrow-up
      8
      ·
      2 years ago

      my humble method: history | grep -i searchterm

    • debil
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 years ago

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

  • jogurt
    link
    fedilink
    arrow-up
    11
    ·
    2 years ago

    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.

    • 0x4E4F@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

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

  • CriticalMiss
    link
    fedilink
    arrow-up
    11
    ·
    2 years ago
    1. vim ~/.inputrc
    2. Paste the following:

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

    Thank me later

    • GuyWithLag
      link
      fedilink
      arrow-up
      4
      ·
      2 years ago

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

    • overtinker
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      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!

      • CriticalMiss
        link
        fedilink
        arrow-up
        7
        ·
        edit-2
        2 years ago

        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

    • TheGeneral
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

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

    • b3nsn0w@pricefield.org
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      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

  • lhx
    link
    fedilink
    arrow-up
    10
    ·
    2 years ago

    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.