• Treczoks@lemmy.world
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    13 hours ago

    Zsh? That’s a command shell I have not heard of for a very long time.

    Check the date on his computer, is it also set to something in the 1980s?

    • uid0gid0@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      21 hours ago

      It’s the index on 1 that ruins it for me.
      Edit: come to think of it what would zsh print out for echo $0?

      • rtxn@lemmy.worldM
        link
        fedilink
        arrow-up
        1
        ·
        5 hours ago

        It follows the same convention as most programming languages that expose the argument list. Python’s sys.argv has the program name at index 0 and the first argument at index 1. C’s char **argv does the same: index 0 is the program name, index 1 is the first argument. So it stands to reason that Zsh’s $0 should be the program name and $1 should be the first argument…

        …which, by the way, is exactly what Bash does as well.

    • boonhet@sopuli.xyz
      link
      fedilink
      arrow-up
      5
      ·
      1 day ago

      Prints out what shell you’re using. Bash is default for most Linux distros. MacOS switched from bash to zsh as their default. Zsh is hella customizable, by default it functions more or less like bash.

      Fish is cool, has neat quality of life features out of the box, but can also break scripts sometimes.

    • Fisch@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      7
      ·
      2 days ago

      Currently using zsh but I installed fish yesterday to try it out because I’m thinking of switching. All the zsh plugins I have are basically just replicating what fish has by default anyway and fish might do it better.

    • flandish@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      2 days ago

      what’s fish got? I’m liking zsh here but am always open to a distraction instead of getting work done. :)

      • null@piefed.nullspace.lol
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 days ago

        Lovely OOTB defaults. I basically change nothing except the theme.

        Autocomplete, git context, etc. The QOL stuff you’d expect.

          • OhNoMoreLemmy@lemmy.ml
            link
            fedilink
            arrow-up
            3
            ·
            2 days ago

            The main differentiator of fish over everything else is it prioritizes intuitive behavior over backwards compatibility.

            Zsh is to bash as c++ is to c. Most bash scripts and habits will work in zsh, but zsh is just more convenient and has more options. Fish is intentionally different.

            Do I wish fish had existed instead of bash so we had a nicer terminal experience? On the whole, yes. But I also couldn’t be bothered to learn another shell where most of the instructions online won’t be able to help you, and I ended up sticking with zsh.

          • Pika@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            0
            ·
            edit-2
            2 days ago

            This is a good way of putting it. It’s essentially ZSH with Autosuggest/complete and a theming agent. At least visual-wise.

            When you get into the scripting and the hot keys aspect of it, they reinvent the wheel and everything is different., Like for example ,!! and other bangs(I think that’s the right word?) like that are not valid on fish, And everything to do with variables is different from adding to your path to setting variables to creating functions. Also checking your error code is going to be different as well as it doesn’t follow the $x style inputs and doesn’t support IFS and globbing works differently.

            TLDR; fish is nice, but If you use it unless you want to relearn an entire type of language, keep your scripts on bash or zsh

            or if you wanna see the bigger differences fish has a dedicated bash transition page

            • Digit@lemmy.wtf
              link
              fedilink
              English
              arrow-up
              0
              ·
              1 day ago

              I never managed to learn bash’s ways in my first decade of using it, learning fish a decade ago was easy by comparison. So much more human readable and sensible and consistent. Even though fish is the friendly interactive shell, I now use it for all my scripting too.

              • Pika@sh.itjust.works
                link
                fedilink
                English
                arrow-up
                0
                ·
                1 day ago

                That was the exact opposite with fish. I had already gotten fairly well first with bash by the time I started using it, and the way fish did it was just super counterintuitive to me.

                I couldn’t get into the overall design of how it looked and I disliked how command substitution and the built in’s worked, Combined with the fact that it’s a lesser used shell, so there’s less information available on it. I just couldn’t do it.

                You brought up a point though. That makes me ask. You must not have to share your scripts with anyone then, right? Fish has a very small user base in comparison to ZSH and Bash and when I make a script that’s more advanced I tend to want to share it with my friends and having them install a whole new shell just to run a script is just not helpful to me. ZSH is close enough to bash in compatibility that, generally speaking, if I want to share it, I can use zsh And then convert the minor discrepancies. Where with fish I have to redo the entire script.

                • Digit@lemmy.wtf
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  edit-2
                  19 hours ago

                  I don’t know why small user base is considered as meaning I must not have to share my scripts. Is it like an argumentum populum thing? [“If you build it they will come.” ;D]

                  [I suppose It’s true in a strict interpretation of those words… I don’t have to.]

                  I think I have several on my git repos. [… I have even written a text editor in fish.]

                  Free to use for anyone who wants to.

                  Also, if user base size is a concern, Fish’s user base is growing faster than Bash or ZSH.

                  Installing another shell seems a trivial matter to run something.

                  I install far bigger languages for far less all the time.

                  And conversion [if for some edge case reason you really need to ~ I know not why though] is generally trivial these days… just ask an LLM, if conversion scripts are lacking.

                  As for the less information about it… the online help’s really rather thorough and accessible.

                  I don’t know that quantity over quality would help. It didn’t for me and bash.

                  Unless I missed something, it seems to me that all that remains, is

                  I disliked

                  And that’s of course utterly fine. Free software’s defining point zero, the freedom to use software, includes the freedom to not use. Good to have multiple options to further facilitate that first freedom, catering to more variety of tastes.

          • Laser@feddit.org
            link
            fedilink
            arrow-up
            0
            ·
            2 days ago

            Be aware that fish isn’t a POSIX-compatible shell enough, so you have to adjust syntax.

            • rtxn@lemmy.worldM
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              2 days ago

              That isn’t incorrect, but it’s not as important as people make it out to be. Linux isn’t certified as POSIX-conformant either.

              People are way too stuck on POSIX regarding Fish specifically, but in shell scripting, POSIX compliance boils down to “can it run a pure sh script”. Bash is compliant. Zsh is partially compliant and needs to set an option to emulate sh. Fish uses a different syntax and is not compliant; if that is a problem, don’t execute sh scripts in Fish.

              POSIX compliance for shell scripts was important in the 80s and 90s when the #! directive wasn’t as commonly implemented and every script might be executed by the user’s $SHELL instead. That is no longer the case as virtually every Unix-like system’s program loader supports #!.

              • Black616Angel@discuss.tchncs.de
                link
                fedilink
                arrow-up
                1
                ·
                2 days ago

                I use fish, but sometimes it acts weird. And lots of “just copy and past this command” kind of online solutions I have to put into bash.

                My main irk is when I want to forward a ‘*’ to a program but have to escape it.

    • prole@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      0
      ·
      2 days ago

      Fish is great if you can’t remember a specific command, or don’t want to type out long filenames/locations, but I dunno if I’d use it as the default.

      I just type “fish” in the terminal if I ever run into a situation where I might get some use from it.

      • Digit@lemmy.wtf
        link
        fedilink
        English
        arrow-up
        0
        ·
        1 day ago

        in my ~/.bashrc

        # if interactive, launch fish
        [[ $- != *i* ]] && return || fish
        

        and

        alias f='fish'
        

        So fish is my default, and if I ever need bash, it’s already there underneath, just a Ctrl-d keybind away to fall back on, and if I want to get back into fish, it’s just a f & RETURN away.

        Seems better to have all the convenience of fish up front. All the completion magic. I so rarely have to type much at all.

          • Digit@lemmy.wtf
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            3 hours ago

            Can cause issues (with things that expect bash or other nearer POSIX compliant shells as the system shell).

            And then I’d lose those other benefits described, like having bash just a keybind away.

            [Edit: I could have swore I got that interactive check in bashrc thing from https://fishshell.com/docs/current/faq.html or other documentation on fishshell.com, but, seems not. Can’t find it even in older copies. Not sure where I picked up that idea from then. Plausibly from someone on irc. I was sure I got that as official advice from fish… which I’ve been using and doing that method with since around 2014.]

  • mlg@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    2 days ago

    Default zsh is just bash, you need to add all the fancy plugins to get it to do cool stuff

    fish is for people who don’t want to spend the time setting it all up and to just get a shell that has most of the QoL fetaures builtin.

        • floquant@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          8
          ·
          1 day ago

          No, they are executed according to the shebang on the first line, which is usually bash. If it is missing, it will default to the current shell.

            • Nalivai@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              11 hours ago

              The situation when people go on stackoverflow and just grab some shit from the top answer and just copy paste in their console is surprisingly normal. Not me, obviously, but like other people do it all the time.

          • Azzu@lemmy.dbzer0.com
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            1 day ago

            That’s true, but I definitely use fish as my default shell and when it runs a script without shebang it automatically runs it with bash. Thus I assume that’s the fish default to make your scripts work.

            • floquant@lemmy.dbzer0.com
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              5 hours ago

              Trying to be more POSIX-compatible by further breaking POSIX spec is an ok choice to make in this case imo, but I think that’s a somewhat important detail to know :)

      • daggermoon@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 day ago

        I tried switching to Nushell but certain things just wouldn’t work so I switched back to zsh. sha512sum wouldn’t work and there’s no native replacement.

        • crater2150@feddit.org
          link
          fedilink
          arrow-up
          0
          ·
          1 day ago

          Isn’t sha512sum a regular binary, that should not depend on the shell at all? What does nushell do that something like that can break o.O

          • daggermoon@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            13 hours ago

            Probably. I think it had something to do with how it’s invoked in Nushell. I think it requires typing something different than what I’m used to. I searched it up and couldn’t find an answer and got pissed off and went back to Zsh. I’m not blaming Nushell, it’s just not for me. Nushell does have it’s own binaries for sha256 and md5, but I prefer sha512 even though it literally doesn’t matter for my use case.

    • Tangent5280@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      2 days ago

      Brave stand, I will stand side by side with you until the first signs of mild resistance or mockery from the world!

      • ulterno@programming.dev
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 day ago

        Well guess what?

        #include <string.h>
        #include <iostream>
        
        int main (int argc, char *argv[])
        {
        	const int which = strcmp ("zsh", "bash");
        	std::cout << which << std::endl;
        	return 0;
        }
        

        Output
        1

    • three@lemmy.zip
      link
      fedilink
      arrow-up
      6
      ·
      2 days ago

      Classic linux tribalism. Use what you like and don’t get involved with these confrontational nerds.

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

      It’s permissively-licensed (as opposed to bash, which is GPLv3). Pushing zsh over bash is part of a larger effort by corporations to marginalize copyleft so they can more easily exploit Free Software at the users’ expense. Don’t fall for it!

      • FishFace@piefed.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 days ago

        It’s such a shame that, if zsh gains enough critical mass, all copies of its source code will be deleted from the universe and no-one will be able to use it without paying any more.

        • grue@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          2 days ago

          It’s such a shame that you can’t customize the version of zsh running on your Linux-based embedded device because it’s DRM’d to prevent the modified version from being installed.

          …oh wait, that’s not sarcasm because it’s actually plausible.

          • FishFace@piefed.social
            link
            fedilink
            English
            arrow-up
            2
            ·
            2 days ago

            Cool.

            And what, exactly, is the path from “pushing back on zsh” to “embedded device manufacturers can no longer lock down their devices?”

            • Shrubbery@piefed.social
              link
              fedilink
              English
              arrow-up
              0
              ·
              2 days ago

              A plausible path is precedent and normalization, not zsh specifically.

              If a widely used copyleft component (like a shell) starts being accepted as “OK to lock down” in consumer or embedded devices, manufacturers and courts get comfortable with the idea that user-modifiable software is optional rather than a right tied to distribution. Over time, that erodes enforcement of anti-tivoization principles and weakens the practical force of copyleft licenses across the stack.

              Once that norm shifts, vendors can apply the same logic to kernels, drivers, bootloaders, and userland as a whole—at which point locked-down embedded devices stop being the exception and become the default, even when the software is nominally open source.

              • FishFace@piefed.social
                link
                fedilink
                English
                arrow-up
                1
                ·
                2 days ago

                I don’t understand. It’s already ok to “lock down” devices, from the point of view of most consumers and the courts, regardless of the software license. Phones make it hard for you to flash new firmware onto them. That is still true with android and the open source components in its stack.

                Using bsd licensed software in every day life cannot accelerate that because it has already happened, and I don’t see how it would be otherwise, because software licensing doesn’t protect against the kind of locking down you’re talking about.

            • namingthingsiseasy@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              2 days ago

              It’s called tivoization and started with a device called “Tivo” which was the first of its kind to attempt this procedure.

              There are probably lots of hardware devices in your house that use GPL software but prevent you from actually modifying it because the hardware will refuse to run modified copies. If a piece of software is licensed GPLv3, it would violate the license terms to do something like this.

  • yardratianSoma@lemmy.ca
    link
    fedilink
    arrow-up
    2
    ·
    2 days ago

    I have never really ever used bash and thought, "Man, I wish my shell was better . . . ". Using ctrl+r to recall past commands, using sudo !! to fix missing permissions and writing small bash scripts all work very well.

    That being said, if you use anything else, and you like it, I’m happy for you, but I do wonder, what leads people to other shells? What problems do they have with bash?

    • crater2150@feddit.org
      link
      fedilink
      arrow-up
      1
      ·
      1 day ago

      I switched to zsh at a time where completion for commands parameters except file paths in bash wasn’t really a thing, you could add some with a script, but they didn’t work well. I’m sure the situation has improved by now, but someone told me recently, there are still no descriptions for the completions. I find it very helpful and it saves me opening a man page a lot of times. For example, typing grep -<Tab> gives me this: 8167

      And now I’m so used to many little features (mostly around the syntax) that wouldn’t be a reason to switch on their own, that I find bash cumbersome to use.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      2 days ago

      To me, it genuinely makes a huge difference that I don’t have to manually press Ctrl+R for history search. Because 9 times out of 10, I accept a history suggestion from Fish where I did not think about whether it would be in my history.

      This includes really mundane commands, like cd some/deeply/nested/path/. You would not believe, how often I want to cd into the same directory.
      But I’ve also had it where I started typing a complicated docker run command and Fish suggests the exact command I want to write, because apparently I already ran that exact command months ago and simply forgot.

      • astro@leminal.space
        link
        fedilink
        arrow-up
        0
        ·
        2 days ago

        I used bash for 20 years and, while I obviously knew that there were alternatives, it never seemed necessary to switch. Tried fish on a whim a few months ago and I will never go back.

        • Ben@feddit.dk
          link
          fedilink
          arrow-up
          0
          ·
          1 day ago

          Do you know if fish can input arguments from prevous commands like ESC + . does in bash?

          • Digit@lemmy.wtf
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 day ago

            Do you know if fish can input arguments from prevous commands like ESC + . does in bash?

            Like Alt-.? (/ Alt - > ).

            Easier in reach, and can cycle through.

            I’ve not got that in my muscle memory yet… so rarely used… had to look that up. Handy. Should use more.

  • MehBlah@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    22 hours ago

    /bin/bash and move on with your life.

    Edit: Oh no one is looking for a solution. I see.