• bridgeenjoyer@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    48 minutes ago

    Nah just save all your commands in a text file on the desktop then make an alias to open it in nano so you just have to type “com”. Works for dumb ol me

  • Zink@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 hour ago

    Ah crap how did I set my battery charge interval again?

    history | grep battery

    history | grep bios

    history | grep sudo smbios

    Ah! There you are you little shit!

    edit to add: Actually, I think the last time I did this I remembered some numbers I set it to before. So it worked well with something like “history | grep 75” even though there were a bunch of results.

    • Buddahriffic@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      58 minutes ago

      Is there a good way to do this when you use a lot of terminal tabs and aren’t sure which tab you used for the command you’re looking for?

  • ___f____g___@lemmy.ca
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    6 hours ago

    I see everyone posting about Ctrl+R, here’s a couple more useful CLI shortcuts you might enjoy:

    cd - (change directory to $OLDPWD usually the previous directory)

    git checkout - (similarly checkout the previous branch)

    Ctrl+A (return caret to beginning of command, great when you forgot a positional argument and you were almost done typing the command)

    Ctrl+E (similar to Ctrl+A but move to the end of the command)

    • YTG123@sopuli.xyz
      link
      fedilink
      arrow-up
      2
      ·
      24 minutes ago

      Ctrl+A, Ctrl+E

      Many more basic Emacs keybindings work, actually! Including C-f, C-b, C-p and C-n (if you prefer them over arrow keys) as well as M-f and M-b to move by words, C-k, M-d and C-y for killing/yanking (but not M-w) and C-SPC, C-w, C-x C-x for region manipulation (tested in Bash and ZSH)

  • neclimdul@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    4 hours ago

    I see so many people loving on atuin in the comments but I just tried it and don’t get it. It seems so much worse than the built in search. I guess it’s not for me.

    • merc@sh.itjust.works
      link
      fedilink
      arrow-up
      3
      ·
      2 hours ago

      I’ve been using it for a few months, and so far it’s not as good as just regular old command history. I think any benefit might be for really, really old commands, or commands happening in a specific location. So, I’m going to keep using it to see if it helps then. But, so far it’s a massive downgrade.

  • JATth@lemmy.world
    link
    fedilink
    English
    arrow-up
    10
    ·
    9 hours ago

    zsh-history-substring-search

    I lazily type part of the thing I want like “sys” and then ctrl+⬆️/⬇️ and sudo systemctl start libvirtd etc. appear like magic.

    • merc@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      2 hours ago

      The worst is when you remember doing something before, but don’t remember enough details to be able to effectively search for it.

      Although, even then, I’m not going to just mindlessly hit “up”. Last time it happened I fed my command history through grep and removed all the things that I knew the command wasn’t. Just removing “ls” and “cd” from your history cuts the number of commands down by 80% or something.

  • Bluewing@lemmy.world
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    9 hours ago

    You know the one command I hate? CTL vs CTRL. There is no damned consistency I can see. Is it systemctl reboot or systemctrl reboot?

  • bdonvr@thelemmy.club
    link
    fedilink
    arrow-up
    64
    ·
    edit-2
    18 hours ago

    I used to be like this but people seriously. CTRL+R

    Do it. Don’t make this one of those things you’ve heard about and just never got around to trying. Open your terminal right now and CTRL+R and type any part of the command you did before. If the command you want is not showing first just hit CTRL+R again to go to the next one back.

    DO IT.

    Edit: I did learn from this thread today though that ZSH has it set to where you can just type part of what you’re looking for then hit up to do the same thing. Neat!