• neclimdul@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    2 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.

  • ___f____g___@lemmy.ca
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    4 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)

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

  • Bluewing@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    7 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
    62
    ·
    edit-2
    16 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!

  • Dave@lemmy.nz
    link
    fedilink
    arrow-up
    8
    ·
    13 hours ago

    Everyone sharing their Ctrl+R tips, here’s my Control+R question:

    How does scope work? Some command history only seems to exist in certain tabs.

    Also sometimes I Ctrl+R in a tab then the command is there but I forget I need a different one first, so I ctrl+c but the next time I search for that original command somehow it doesn’t exist anymore.

    I’m using the default terminal on Nobara (fedora based).

    • PotatoesFall@discuss.tchncs.de
      link
      fedilink
      arrow-up
      9
      ·
      edit-2
      11 hours ago

      This actually doesn’t depend on your terminal but on the shell running inside it. Bash is the default on most distros. I have also frequently had this issue. There might be config to fix it.

      I switched to fish instead of bash, and now I use fzf and the https://github.com/PatrickF1/fzf.fish plugin and it works GREAT. There might be a similar thing for bash, I don’t know.

    • Trail@lemmy.world
      link
      fedilink
      arrow-up
      12
      ·
      13 hours ago

      As far as I remember, there is a bash setting that controls whether the command history is written immediately after execution (in which case it is immediately available on all tabs/windows of the console) or after closing the session (in which case it will be available next time/potentially lost if the window is forcibly closed etc).

      The default is the second one as far as I remember.

      That said, I had changed to a more powerful one in zsh years ago, so it’s been a while…

      • Dave@lemmy.nz
        link
        fedilink
        arrow-up
        1
        ·
        10 hours ago

        Thanks, I worked it out. Not a setting as such, but you can use PROMPT_COMMAND to run an action to insert into history each time a prompt is run, as described here.

        Though I have started down a rabbit hole of looking at other options for the shell.