73 comments

[ 5.3 ms ] story [ 156 ms ] thread
Been meaning to move fully to Fish, was just dreading the amount of zsh functions I'd have to rewrite.

Is there any reason to use Zsh at this point over Fish?

I was in a similar situation 2 years ago and I took the plunge. Turns out, the amount I had to rewrite was fairly minimal, and the benefits of Fish are just incredible. I'd say: go for it, you won't regret it!
zsh tends to actually run scripts when you feed them. As long as you can resist the urge to run all of your POSIX scripts in fish, I think I much prefer fish as an interactive shell.
Exactly. Falling back to Bash to run scripts makes life easier. Just add a Bash shebang at the top and you're good to go.
process substitution?

fish: Invalid redirection target: yq3 r <(kubectl get nodes -o yaml)

You can do process substitution by piping into the psub command ;)
I used fish for a long time, but lost patience with the incompatibility with other shells. It’s nice to be able to just paste and run someone else’s command, and I eventually tired of having to rewrite every command to use fish syntax. For example, replacing FOO= with set - x … The reverse is even worse—if I need to send someone a command to run, I have to rewrite it in a syntax that’s likely to work when they run it. It only takes a few seconds each time but I grew weary of it.
That’s accepted now, and was always available by prepending env.
You can just do `bash -c "CMD"`.
occasionally you'll need to run a command which sources or exports… it's no silver bullet in my experience anyway
Check out fish-foreign-env, bass, and babelfish
create a key-binding to invoke your terminal with bash. I have not set fish as my system shell (aka chsh)
They have improved compatibility a lot.

Also, you could do what I do: leave bash or something else as the default, and then just run fish manually.

Then if I have a problem pasting or something I run type exit.

But the incompatibilities are a lot less now.

Personally, I'm a lover of subshells, I often write things like (cd mydir && make), making use of the fact the 'cd mydir' only happens in the subshell.

Fish doesn't have anything like that, there are a few workaround, but none of them are (in my opinion) anywhere near as nice.

I use this a lot in my scripts - handy when you want to capture the output or execute a command in a different directory.

    set output (echo captured)
    echo $output
    > captured
And if you wanna run a command in another dir:

    pushd other_dir
    run_command
    popd
If it's just make you're doing that for "make -C mydir" does that and puts you back in the original directory when it's done.
I do this too (in zsh), but maybe writing a function callable like this would work:

  with mydir make
Although you'd want to be able to write things like

  with mydir make && ./bin/myprog
and parse everything to the right of `mydir' as a shell pipeline. That might be the sticking point in fish.
You should instead

    pushd /my/path && command && popd
Both in bash AND in fish!
the problem with that is I ended up in the wrong directory if I press ctrl+c, or in the exact examples you give, if command fails.
Last time I looked into switching the vim mode in zsh was better by enough of a margin that I didn't switch, but that was years ago. I've been meaning to give fish another shot.
zsh has survived for longer (it's "Lindy") and is therefore more widely available on remote machines. Also, maybe just my problem, but I do get frustrated having to switch back to bash/zsh syntax and semantics in cases where Fish isn't available, or when writing scripts others will use. Easier for me to stick with zsh for my shell and bash for shipping shell scripts.
You can 1. Make your scripts executable or 2. Use bash / zsh inside of fish. 3. You can define wrapper functions in fish that just call bash/zsh functions internally. I use fish, although I hate writing scripts in it. It just feels wrong. Better stick to good old bash.
For copying and pasting while preserving environments, you can always use `exec` as an escape hatch.

  exec bash
  <paste some bash>
  exec fish
> Added completions for:

> archlinux-java (#8911)

> apk (#8951)

> brightnessctl (#8758)

> efibootmgr (#9010)

> fastboot (#8904)

> optimus-manager (#8913)

> rclone (#8819)

> sops (#8821)

> tuned-adm (#8760)

> wg-quick (#8687)

One of my favorite things about fish is that it bundles completions for a huge number of packages. My experience with bash was that completion support was very spotty

Zsh Completions is a pretty good alternative for anyone using zsh.

https://github.com/zsh-users/zsh-completions

Zsh completions can be hit or miss. Sometimes they make huge differences to how path argument selection works (tab completion) in confusing ways that are inconsistent between commands.
Great! Love the new Astronaut prompt. I dabbled with starship.rs, and really liked the prompt, but ultimately didn't want to deal with an extra moving part in my terminal setup. I'm so happy that some of it is available in stock fish shell, now.
I love fish, it's become my main daily driver. :)
Fish shell has far better history and autocompletion UI, and an actual Web based UI for config.
Who wants a web-based tool for configuring terminal apps? Sounds like a mismatch to me.
What would you prefer? You can always manually edit config files, or you can have a UI that lets you preview how various things will look and simplify changes. Seems like the best of both worlds.

Have you tried it?

Could be useful the first time, but after that just clobbers things? Ten themes are not enough for any but the most casual users. These cases don’t fit the terminal well.

If it were a curses app with complete (or non-clobberful) customization I might see the point.

Sorry what gets clobbered?

If you only need it once, just don’t launch it again? It’s not like it’s always running.

You edit files, or use the interface. Much is configured through custom written functions. If you use both there is likely to be trouble.
I really love fish and used it daily for many years. Then I started work at a new company that had an existing library of internal shell tools that weren't compatible with Fish and the effort to port them was too much.

I found that ZSH managed with OhMyZSH plugins gets me similar functionality without the syntax incompatibilities. Unfortunately unless Fish moves back towards compatibility I don't see myself ever going back, it's just too much hassle dealing with little syntax issues all the time.

I’m an avid bash user for the same fear of incompatibility. But how does that work in practice? I mean- if I use Fish shell interactiveley, how does that affect shell scripts? I presume they would still be run via bash (#!/bin/bash)
Every script should have a #! line, but if it doesn't, you can always run it with `bash <script>`.
Could be "add source /blah blah" to your bashrc, and this adds some shell functions (which allow it to do stuff like cd).
Executing programs (including scripts, which are indicated by shebangs like #! /bin/bash) is the operating system's responsibility, not the shell's.

So yeah, shell scripts work exactly the same if you're running them as an executable. Some scripts, however, (like for instance .bashrc) are intended to be sourced by the shell rather than invoked as an independent executable. These won't work, and will need to be ported.

Same here, fish is amazing until is isn't. I really wish it was POSIX
Ditching some of the POSIX missteps is half the appeal of fish.
Why did you need to port them? The occasional simple shell script I write in bash. You can just use fish interactively.
I'm running fish for at least 8 years now and I'm very happy with the out of the box experience. It's one of the first things I install on new machines.
> ampersand-nobg-in-token, which means that & will not create a background job if it occurs in the middle of a word. For example, echo foo&bar will print “foo&bar” instead of running echo foo in the background and then starting bar as a second job.

Yes! This has been annoying with curl for a long time.

Since such URLs very often come from copy & paste another way to deal with this is smart auto-quoting when a paste is detected via the "bracketed paste" feature of modern terminal emulators. zsh does this if you enable url-quote-magic.
Fish also enables bracketed paste and does smart escaping when you paste inside single-quotes.

(I'm a fish developer)

I used to like fish, but because of compatibility issues, I went back to OMZ (:
Have you tried it recently? It's gotten a lot better. The following commands used to not work, but now they all do:

    true && echo hi
    false || echo hi
    export VAR=1
    VAR=1 somecommand
    echo "$(echo substitution)"
If I'm not a "power user" (learned rudimentary bash as teenager, stuck with it on MacOS through college) is it worth it to learn a new shell?

I respect the craftmanship, but if I'm more of a "software carpenter" why should I invest the time?

For me, fish made my life instantly better without any real investment coming from bash. There are some incompatibilities, but I felt productive right away.
I always recommend fish to anyone who doesn't (yet!) have strong opinions about their shell.

Immediately seeing if you misspelled a command because the color changes is a huge benefit if you're not super familiar with the command line.

The auto-complete and suggestions are also miles better than bash - they are automatically generated from man pages, so most commands have a usable set of completions.

The web-based config lets you easily tweak settings that would otherwise be an incomprehensible soup of PS1=3!@*(!@!@ gobbledygook.

Also, it mostly "just works" out of the box, so you really don't have to waste any time setting anything up if you don't really care.

Sounds promisingm, especially now that macOS defaults to Zsh... I very rarely see any documentation where that is the default.
> The auto-complete and suggestions are also miles better than bash - they are automatically generated from man pages, so most commands have a usable set of completions.

I never understood this. It's always seemed worse - in bash/zsh I can tab complete branches/tags etc in git, pods/deployments etc in kubectl. I try that in fish and it'll just list files in my PWD

Fish to me is like writing a document in Word. Bash is more like writing it in Notepad. (or whatever Linux equivalent you want to use)

Though I still write my scripts as bash scripts (with shebang as the first line).

I used zsh for years with a moderately elaborate configuration that grew into a pain in the ass to manage. I started using fish a few months ago with no configuration of my own. I'm still not sure if I'll stick with it in the long run, but if nothing else it's a welcome reprieve.
The auto-completion alone is worth it IMO. I've been using fish for 6 or 7 years now, and having it hint ahead some obscure command that I only use once a month saves me so much time reading MAN/searching online.

Pair that with tldr and it's a really good experience.

Yes, it's worth it! Fish is especially great for users who have found learning bash troublesome or uninviting. It's simpler and easier to learn, and plus it has very pleasant defaults and builtins. If you get started with Fish, you're much more likely to learn advanced functionality because the journey is more enjoyable than with bash.
This killed all shell interaction within my tmux setup, somehow, and I had to downgrade in osx/brew [1] back to v3.4.1 [2]. I'm still wondering what part of my (probably outdated) tmux config caused it, but the most suspicious part is the run-shell/if-shell stuff.

Anyway, have things to do before I can try again and dig in. Thought I'd post in case someone else ran into this.

[Edit] Tip: swap to a different shell before uninstalling your current shell. Sigh...lol

[1] https://github.com/fish-shell/fish-shell/issues/5497 [2] https://raw.githubusercontent.com/Homebrew/homebrew-core/ad5...

[Late Update]

The fish 3.5.0 release is not responsible for my tmux issue. False alarm.

Downgrading did somehow help me regain shell interaction, but I can't create a new session/pane, etc.

I think something else broke my tmux setup during the brew upgrade, or possibly even before it.

Fish is fantastic. Some people worry about posix compatibility and stuff, but that only matters if you are copy pasting bash snippets directly to the command line. If you are using bash or zsh as a programming language then you put the code in a file, and run it with that shell - so it doesn't matter what shell you are running.

If you love bash or zsh, and are in the habit of building long complex commands on the command line, then stick with bash or zsh. But if you are just running commands fish is far superior. If you are not a bash/zsh/posix expert fish is a cleaner language and you'll learn it more easily. A fully tricked out zsh might do everything that fish does, but it is very slow compared to fish.

> If you love bash or zsh, and are in the habit of building long complex commands on the command line, then stick with bash or zsh.

Fish handles this very ably as well, of course! If you're a developer and you work in or deploy to a lot of environments where you can't install software, choosing what comes with the environment makes sense. But even when it comes to scripting, you won't regret sticking with Fish, imo.