• dreadbeef@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    5 days ago

    Fish once again undefeated. If I want to find that weird image magick command I used earlier with foo.png in it I just type foo.png, hit up and its usually the first one. It doesnt matter where foo.png occurs in the command, fish will find it.

      • baltakatei@sopuli.xyz
        link
        fedilink
        arrow-up
        1
        ·
        5 days ago

        That’s when you start spamming Page Up/Down, Home, End, and / to search within less. Usually seeing various commands jogs my memory, especially when they are grep commands searching for one I use often enough to be useful but infrequently enough to not remember off the top of my head.

    • zarkanian@sh.itjust.works
      link
      fedilink
      arrow-up
      6
      ·
      edit-2
      6 days ago

      Aliasing cat or any other ubiquitous shell utility to a replacement is a mistake. Garuda did this, and it was driving me crazy why cat was giving me errors. Turns out that they had aliased bat to cat, and since bat is a different program, it didn’t work in exactly the same way, and an update had introduced some unexpected behavior.

      Drop-in replacements are dumb. Just learn to use a different command.

      • janAkali@lemmy.sdf.org
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        6 days ago

        I think it’s ok to add this in a personal .zshrc, not on a distro level:

        If it breaks something - I’d probably know why and can easily fix it by removing alias/calling cat directly.

        Also, scripts almost always use bash or sh in shebang, not zsh. So it only triggers if I type cat in terminal.

        • psud@aussie.zone
          link
          fedilink
          English
          arrow-up
          1
          ·
          5 days ago

          It’s better to learn the new command, then it still works when you use a different machine that doesn’t have your alias

          • janAkali@lemmy.sdf.org
            link
            fedilink
            arrow-up
            1
            ·
            4 days ago

            If you are me, there is no brain space for remembering new commands. I can already barely hold on to few dozens that I use often. And occasionally when I need “that one that does that niche thing… how was it?” program - I just sit there sifting through logs for couple minutes.

            Today it was od (tbh it’s od almost half the time; not really the best name to memorize (I really need to make a note or something, so I stop forgetting it, lol))

            Also, for this reason I went to great lengths to keep my ~/.zsh_history protected from being randomly deleted/overwritten by mistake, as it happened a couple of times. Currently it’s sitting at around 30_000 lines, oldest command is 2 years old.

      • merc@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        edit-2
        7 days ago

        Yeah, true. But, it’s easy to change.

        Bash is the Internet Explorer of shells. It’s great for installing a more useful shell.

        • layzerjeyt@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          5
          arrow-down
          1
          ·
          7 days ago

          That’s super unkind and incorrect. IE was a trash software that was widely available because MS was trying to extend their monopoly into new areas.

          Even if it’s not your taste, bash is a mature, stable FLOSS package with wide community support. The reason it is so common is due to it’s positive attributes, not because there is a plot to make it the only choice available to you.

          • calcopiritus@lemmy.world
            link
            fedilink
            arrow-up
            2
            arrow-down
            1
            ·
            7 days ago

            Bash might be better than IE. But I think we can agree that it is no longer a good shell.

            Its syntax is awful, and lacks many features that other shells have.

            It is only so widely used because it is a de facto standard. If bash was created today, barely no one would us it.

            • Auli@lemmy.ca
              link
              fedilink
              English
              arrow-up
              0
              ·
              7 days ago

              My problem with those is bash is always there and just works.

              • merc@sh.itjust.works
                link
                fedilink
                arrow-up
                3
                ·
                7 days ago

                Yes, just like Internet Explorer.

                It’s good to know how to do things in bash, since you’re going to encounter it pretty often. But, that doesn’t mean you shouldn’t customize your shell on the machine(s) you use most often. Why stick with the default when there are better options? You’re just hobbling yourself.

    • xoggy@programming.dev
      link
      fedilink
      English
      arrow-up
      1
      ·
      6 days ago

      Not sure I understand the point of mcfly. zsh and fish have this functionality built in, where pressing Up with a command partially typed will give auto-completions to that partial match.

      • MashedTech@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        6 days ago

        Yeah. I also use auto-completions for that. McFly does fuzzy finding and because it’s a different separate db, for me it works better across many sessions to find commands I had just recently used in another session.

  • T156@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    7 days ago

    Being able to just enter a partial command, and hit [up] to jump to prior commands that started in the same way in zsh is a godsend.

    • Entitle9294@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      7 days ago

      If you ever have to go back to bash, it supports it as well. In my bashrc:

      bind '"\C-p":history-search-backward'
      

      That’s ctrl-p, but I’m sure the up arrow is possible too.

  • wewbull@feddit.uk
    link
    fedilink
    English
    arrow-up
    3
    ·
    7 days ago

    The one people see me doing that gets a “huh?” Is:

    ~$ !find
    find -type f -name '*blah*' -print0 | xargs -0 gzip
    ~$
    

    “Wait! What did you do?” “Oh. Do you not know about bang?”

    • UpperBroccoli@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      8
      ·
      7 days ago

      I love the excitement of using !?

      Did I remember correctly what command sequence I last used that pattern with? Will my data be gone? Will I send a vulgar email to my boss? Who knows, let’s find out!

    • merc@sh.itjust.works
      link
      fedilink
      arrow-up
      6
      ·
      7 days ago

      I don’t understand people who have the confidence to just blindly run the last matching command like that. Like, are you 100% sure that the last time you ran find was that one, not the one that piped to xargs rm?

      At least with zsh you can tab to complete the !find and verify it’s what you want before running it. And, AFAIK by default, the shell option hist_verify is set, so if you do just type !find and hit enter, it doesn’t run the command, it loads the command into the editing buffer so you can look it over first. Maybe I just have a weak memory, but I really appreciate the footgun prevention. At worst I have to hit enter twice. At best, I save myself a lot of grief.

      • wewbull@feddit.uk
        link
        fedilink
        English
        arrow-up
        1
        ·
        6 days ago

        Normally the use case is

        • Constructed a long command, but it didn’t work for some reason.
        • I go fix the reason it didn’t work
        • I do the first thing again

        It’s in my recent memory, but maybe there’s been 10 or so commands of me fixing stuff in-between.