Fish shell, a popular user-friendly command-line shell, has announced version 4.2, a new release that builds on the 4.0 series. Among the most visible improvements is an upgrade to history-based autosuggestions, which now properly handle multi-line commands.

Fish 4.2 also improves how prompts are managed: transient prompts that contain more lines than the final one are now cleared properly, preventing visual clutter on screen. Similarly, the shell now hides parts of a multi-line prompt that have scrolled out of view, eliminating duplicated lines after repainting.

  • vortic@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    edit-2
    18 hours ago

    What benefits does a shell like this have over bash and how hard is it to transition?

    • 1984@lemmy.today
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      5 hours ago

      You have many better shells today, like zsh and fish.

      Unless you need to concert shell scripts, specially zsh will just work. Fish has some of its own syntax for environment variables, and requires quotes sometimes in commands, so its a bit different but easy to learn.

      I use fish myself because i really like the way it does auto complete out of the box. You can get that with zsh as well but it requires more config.

    • tyler@programming.dev
      link
      fedilink
      arrow-up
      4
      ·
      6 hours ago

      There is functionally no benefit to using bash and there hasn’t been for over a decade. Even macOS transitioned to the default shell being zsh. In terms of user friendliness, fish outcompetes zsh and bash handily. The only other shell I’ve heard ‘beats’ fish is nushell. But I’ll never go back to zsh or bash. Needing to drop into bash to run a script can always be done if you need it, but your scripts will be easier to read in fish.

    • platoose@feddit.uk
      link
      fedilink
      English
      arrow-up
      34
      ·
      edit-2
      20 hours ago

      it has loads of features that would require extensions or plugins in bash, like autocomplete, abbreviations, or fancy prompts, except they all work out of the box and with minimal configuration and behave intuitively

      fish is also a much nicer language to write scripts in than bash

      totally painless to transition, your bash skills are all transferable

      • Victor@lemmy.world
        link
        fedilink
        arrow-up
        18
        ·
        19 hours ago

        fish is also a much nicer language to write scripts in than bash

        I rewrote my entire ~/.local/bin repo of scripts from bash to fish and they are probably 50% shorter on average, actually understandable after not reading them for 6 months so highly maintainable, and actually fun to write in comparison. Argument parsing is also such a breeze.

        I love it. Been using it a few years now and I’ll never use a Bourne style shell again, interactively. Nushell is the only other type of shell I’ve my eyes on, but that seems more useful if I’m in a position where I need to process a lot of data like logs or something.

        • UnfortunateShort@lemmy.world
          link
          fedilink
          English
          arrow-up
          7
          ·
          edit-2
          19 hours ago

          At the end of the day, fish is still a language for the shell, hence not necesaarily readable if you don’t pay attention to that kind of thing. The difference is that the special-character count drops by like 80% and it is actually possible to write something readable. Imo this is next to impossible in bash. Also their builtins are pure love. The string command covers pretty much anything you might ever wish to do with any kind of string.

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

          i made the transition from fish to nushell and can confirm all this stupid JSON data and YAML config was the reason

      • Scipitie@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        4
        ·
        19 hours ago

        If on he other hand you want a transition that’s really painful and slow but sooo rewarding (highly subjective, of course) you can look into nushell. They just said “screw this 50 years of conceptual baggage and let’s do it data centric and proper”.

        I still am at perhaps 10% the speed of my zsh setup but the concepts are so intriguing I’m sticking to it. At least I try to …

    • Oinks@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      14
      ·
      edit-2
      19 hours ago

      This is by no means complete, but the features that I value would be:

      • <Tab> cycles though completions as it should instead of duplicating the prompt.
      • Completions also show help text (if there’s a provider for one). For example on git <Tab> it shows a short message describing what the command does. JJ goes further: jj diff -r <Tab> shows part of the commit message for the offered commits.
      • There are just more completions than in any other shell I know. Aside from JJ the new Nix CLI also has great Fish completions and can dynamically complete flake outputs like package names.
      • Entire commands can be history completed with <C-E> or <Right>. This completion is also directory-aware and can usually avoid suggesting commands with paths to files that don’t exist. In practice I find that it’s really good at suggesting the command I actually want to run, to the point that I rarely invoke FZF anymore.
      • Abbreviations are in most cases better aliases since they do the same thing but don’t obscure what you’re actually running.
      • No word splitting when expanding variables, because it’s never what you intended.
      • Globs that fail to match anything are errors instead of silently doing the wrong thing.
      • Control structures are a bit nicer (but that is subjective).

      You can get most of these with liberal use of shell options, installing blesh, or alternatively installing zsh with a bunch of plugins, but Fish just has all of them out of the box. You don’t even need bash-completions.

      how hard is it to transition?

      It has a reputation of being very difficult from the past when it didn’t have &&/|| but I think today plenty of Linux users would not even notice. The most notable remaining differences are setting variables (requires the set builtin unless used to modify the environment for a single command), control structures (irrelevant in interactive use) and lack of !! (but you can make an abbreviation to bring it back).

      • Cris@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        27 minutes ago

        Any chance you could give a simple explainer on how to set up a !! abbreviation in fish?

        I’m a fairly non-technical fish user and every time I’ve tried to figure out how to do it I’ve ended up giving up 😅

        If you don’t know off the top of your head thats fine, but it seemed worth an ask ☺️

    • pryre@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      17 hours ago

      For me, a full transition never really worked. I’ve needed up using bash for my login shell to keep general compatibility, then GUI terminals, etc, all get started running fish. Most of the scripts I write still use bash, but the thing I interact with 90% of the time is fish and it’s out of the box features cover everything I could want for those times.

      There’s also tools like “bass” that help for situations where you need to do “source xx.bash” to get dev environments running.

      This setup to me is pretty much painless, and doesn’t require any upkeep. All wins.

    • tom@jlai.lu
      link
      fedilink
      arrow-up
      9
      ·
      19 hours ago

      Fish is great out of the box!

      Check out the Fish for Bash users guide since it explains the main differences.

      The few issues I’ve seen for daily use are that export does not work and you need to use set -x VAR value instead, $PS1 is not recognized because Fish uses its own prompt system, and wildcards work a bit differently…

      • rozodru@pie.andmc.ca
        link
        fedilink
        English
        arrow-up
        4
        ·
        16 hours ago

        it really is fantastic out of the box. When I switched to NixOS I had decided to stay on zsh/ohmyzsh and it was an absolute slog. it was so slow and didn’t mesh well with the zsh plugins. Someone suggested I try Fish instead as it pretty much could do what Zsh does with plugins but right out of the box. Fish was much faster and indeed could do everything that I had configured zsh to do but I didn’t have to configure Fish at all. It’s great, I’ll never use another shell.

        • Victor@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          8 hours ago

          In fish, man export:

          export is a function included for compatibility with POSIX shells. In general, the set <> builtin should be used instead. When called without arguments, export prints a list of currently-exported variables, like set -x.

          So it’s not really a proper built-in command, but a wrapper around set. But for all intents and purposes… 👍