• JATth@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months 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.

    • apftwb@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      ⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️

      CTL+C

      history

      history | less

      ⬆️⬆️⬆️

      Pg-up

      Pg-up

      q

      ! 2648

  • bridgeenjoyer@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    3 months 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

  • ___f____g___@lemmy.ca
    link
    fedilink
    arrow-up
    0
    ·
    3 months 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
      0
      ·
      3 months 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)

  • PhAzE@lemmy.ca
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    Ctrl + R and start typing the command, it’ll come up, press enter. Im just more lazy because I know there are still faster ways.

      • abbotsbury@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        3 months ago

        fellow fish user, I just like its autocomplete and how I can just type ‘help’ and an interactive HTML page opens up where I can look stuff, and fish_config does the same except with settings and themes

  • Bluewing@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    3 months 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?

      • ozymandias@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        3 months ago

        type part of the command, then press up and it’ll complete it from your history….
        also i suggest Oh-My-Zsh for nice colors in the terminal
        the first time you do it you’ll get angry at all the time wasted in bash… also with oh my zsh it’ll show you what branch you’re in in a git repository… it’s great.

        • Tja@programming.dev
          link
          fedilink
          arrow-up
          0
          ·
          3 months ago

          Thanks! I have zsh on some of my machines, and installed zpresto on some but never got the advantages… probably due to bash muscle memory.

          You also can get the git branch in bash, and a bunch of other $PS1 customizations are also possible (Tmux, ssh, time, background processes, etc).

          I’ll try the up completion later :)

          • ozymandias@lemmy.dbzer0.com
            link
            fedilink
            arrow-up
            0
            ·
            3 months ago

            yeah you can do anything in bash….
            zsh is really just an extension of bash, imo…
            but the completion alone makes it worth it for me.
            also colors in the terminal

  • bdonvr@thelemmy.club
    link
    fedilink
    arrow-up
    0
    ·
    3 months 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 it’s not showing first just hit CTRL+R again to go to the next one back.

    DO IT.

  • MehBlah@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    If I haven’t ran it in a while or I don’t know it by heart then I ‘nano /home/mehblah/.bash_history’

  • Reygle@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    … And waste an opportunity to type on my ludicrously expensive mechanical keyboard?

    FRIG no