I’m moving my posts from Reddit to Lemmy before delete them.

This post is from 2020-09-03.

  • @[email protected]
    link
    fedilink
    English
    221 year ago

    Okay, you guys get the once in a liftetime chance to convince me that Bash is not the way to go. I’ll eagerly await your proposals.

    • Like A Duck
      link
      fedilink
      English
      26
      edit-2
      1 year ago

      Zsh, an extended version of the Bourne Shell (sh), offers a plethora of compelling reasons why it surpasses Bash in terms of functionality and customization. Here are some key advantages of Zsh over Bash:

      • Plugin and theme support: Zsh boasts a wide range of plugin frameworks and themes, allowing users to enhance their shell experience and tailor it to their specific needs. The popular Oh-My-Zsh framework is a testament to the vibrant plugin ecosystem available for Zsh.

      • Automatic cd: Zsh simplifies directory navigation by enabling users to change directories simply by typing the name of the desired directory. This feature eliminates the need to type the “cd” command explicitly, saving time and keystrokes.

      • Recursive path expansion: Zsh offers the convenience of shorthand path expansion, allowing users to expand a partial path to its full form recursively. This feature proves particularly useful when dealing with nested directory structures.

      • Spelling correction and approximate completion: Zsh’s intelligent auto-correction feature automatically fixes minor typos in directory names, ensuring smooth and error-free command execution. Additionally, Zsh’s approximate completion feature suggests potential completions based on the entered command, further streamlining the workflow.

      • Syntax highlighting: Zsh goes beyond mere text display by providing syntax highlighting for command lines, making complex commands more readable and easier to comprehend. This feature enhances code visibility and reduces the likelihood of syntax errors.

      • Advanced scripting capabilities: Zsh offers a more powerful scripting language compared to Bash, enabling users to create intricate and sophisticated shell scripts. This flexibility opens up possibilities for automation and complex task execution.

      • Enhanced customization: Zsh provides users with extensive customization options, allowing them to personalize their shell environment to suit their preferences. From prompt customization to theme selection, Zsh empowers users to create a shell experience that aligns with their workflow and aesthetic choices.

      While Zsh undeniably offers a wealth of advantages, it is worth noting that it has a steeper learning curve compared to Bash, especially for users unfamiliar with advanced shell features. Additionally, Zsh consumes more memory due to its more complex data structures and advanced functionality.

      • @[email protected]
        link
        fedilink
        English
        41 year ago

        Some of those options exist in Bash too, but need to be enabled in your profile: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html. Bash is also more like to be available on random machines that you have access to. Lastly, if you’re working a lot with Bash scripts in your (work) environment you might feel more at home using Bash in interactive mode too.

        Those are just some counter arguments for the sake of completeness. I think zsh is great, even though I personally don’t use it (yet).

        • Gamma
          link
          fedilink
          English
          21 year ago

          Yeah, from the first line

          Zsh, an extended version of the Bourne Shell (sh)

          This screams AI-generated.

      • @WIPocket
        link
        English
        21 year ago

        Automatic cd isnt a zsh-only feature. You can use it in bash by shopt -s autocd. Afaik its also disabled by default in zsh, just enabled by oh-my-zsh.

      • @[email protected]
        link
        fedilink
        English
        21 year ago

        Automatic cd: Zsh simplifies directory navigation by enabling users to change directories simply by typing the name of the desired directory. This feature eliminates the need to type the “cd” command explicitly, saving time and keystrokes.

        What if there happens to be a command with the same name?

          • @[email protected]
            link
            fedilink
            English
            21 year ago

            Then you’re likely to enter a command by accident. I would consider that a dangerous misfeature and look to turn it off.

            • Gamma
              link
              fedilink
              English
              11 year ago

              I’ve got syntax highlighting enabked, so I always notice the different color when I type a commnand.

    • Gamma
      link
      fedilink
      English
      6
      edit-2
      1 year ago

      There are two massive points no one has mentioned yet.

      • Quoting every expansion isn’t necessary in Zsh. Parameters don’t split or glob by default.
      • $array actually expands to every element in an array.

      Compare this between Bash and Zsh:

      a=('/* hello */' 'world!' '  ')
      printf '"%s" ' $a
      
      • @[email protected]
        link
        fedilink
        English
        4
        edit-2
        1 year ago

        $array actually expands to every element in an array.

        Very convenient. But ~every shell script is written in bash or POSIX(y) sh. When I need to write shell scripts I begin with busybox sh compability. If it turns out to be too complex, I’ll convert to bash. This is because if I ever would publish the script it would have better changes to be accepted as a PR for example. Yes. Bash is a mess. I don’t even like it that much. It’s okay. But it’s more standard then zsh. Although I’ve seen the tides turn on some occasions, like macOS.

        Maybe some day I’ll give zsh a second chance.

        • Gamma
          link
          fedilink
          English
          21 year ago

          I used to write Bash more than anything, but now the things I write are either simple enough to keep POSIX or complex enough that I miss the extra niceties Zsh provides.

          • @[email protected]
            link
            fedilink
            English
            11 year ago

            but now the things I write are either simple enough to keep POSIX or complex enough that I miss the extra niceties Zsh provides.

            Well said!

  • @Thaurin
    link
    English
    71 year ago

    Try fish with the tide plugin and the fzf plugin. I can never go back to anything else.

    • samsy
      link
      fedilink
      English
      11 year ago

      I love fish, only it annoys me, if I want to run a bash script.

      • @Thaurin
        link
        English
        21 year ago

        Why is that? You can still use bash to interpret your bash scripts. Where does it annoy you?

        • samsy
          link
          fedilink
          English
          11 year ago

          I have to switch to bash first, and wonder days later, why I can’t find it (obviously) in my fish history.

          • @Thaurin
            link
            English
            6
            edit-2
            1 year ago

            I mean, doesn’t the script have a hash bang pointing to the bash interpreter?

            #!/usr/bin/bash
            

            Or you can just run it like:

            bash script.sh
            
              • @Thaurin
                link
                English
                51 year ago

                Right, of course. I already do that with Python scripts, but with bash old habits die hard, I guess. :)

            • samsy
              link
              fedilink
              English
              21 year ago

              I know, well the lazyness is strong in me. Copy and paste.

              • @Thaurin
                link
                English
                5
                edit-2
                1 year ago

                Huh. It’s the first thing I write in any script. It actually saves me time. What annoys me is a script that doesn’t have a hash bang. :)

    • @Melco
      link
      English
      11 year ago

      deleted by creator

      • @Thaurin
        link
        English
        3
        edit-2
        1 year ago

        The command-line completion features alone are worth it!

        Watch this video for a short introduction of some of the features.

        • @Melco
          link
          English
          11 year ago

          deleted by creator

          • @Thaurin
            link
            English
            1
            edit-2
            1 year ago

            I’m not sure if it’s the tides prompt or standard fish, but it shows me a match from my history as I type. So it’ll get more accurate the more I type. Then I’ll just hit control-e and it’ll complete it! I used to use control-r in bash for that, but this is way faster and more fluent. Also, the fzf plugin has a much more useful control-r replacement with fuzzy searches, etc.

            The only downside would be the stuff that you know and are used to in bash and have to figure out in fish, or if you need to write any scripts that are POSIX-compliant. But you can still script in bash, of course. Although the fish language is more readable, it’s still a new language to learn. So if you do lots of cool internal functions and loops on the bash command-line all the time, well either learn fish or you start a bash shell and do it there. It’s not like bash suddenly isn’t available anymore.

            • @Melco
              link
              English
              11 year ago

              deleted by creator

              • @Thaurin
                link
                English
                1
                edit-2
                1 year ago

                It’s been a while since I’ve tried zsh, to be honest, but from what I can remember and what I’ve seen online, is that fish a little bit more “modern” and has sensible defaults out of the box. While you can probably achieve the same with zsh (and probably bash as well, with lots of tweaking), fish is just easier to get up and running as supposed to having zsh and installing some sort of plugin manager such as “oh my zsh” and researching and installing a bunch of things yourself.

                My experience with zsh wasn’t amazing, maybe because it may have required a bit of tweaking and I didn’t feel like it at the time. For fish, I just changed the shell, researched a little about available plugins, and decided I wantef fzf and tide, and that’s basically it.

                I don’t know if either fish or zsh is more customizable, but I’m happy with it. Bottom line appears to be, zsh has been around very long, like bash, but fish is much newer, therefore feels more “modern”, whatever that may mean. The flip-side of that is that zsh is a bit more like POSIX-compliant, even though I don’t think it really is. So zsh is more like bash than fish is, while offering more features than bash.

                Try out both, if you have the time. :) If you don’t have the time, go with fish.

    • @[email protected]OP
      link
      fedilink
      English
      71 year ago

      Automation can get you blocked from posting apparently, also I didn’t have that many posts so I handpicked them.