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
    1
    ·
    edit-2
    17 days ago

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

    • Oinks@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      1
      ·
      18 days 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).

    • rarsamx@lemmy.ca
      link
      fedilink
      arrow-up
      1
      ·
      16 days ago

      For me:

      • Better auto complete.
      • Better scripting language
      • Easier to create built in functions
      • Nicer prompt configuration

      There may be some others but I find Bash clumsy (or maybe I’m just clumsy in bash) when I need to use it.

    • tom@jlai.lu
      link
      fedilink
      arrow-up
      0
      ·
      18 days 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…

        • Victor@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          17 days 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… 👍