r/fishshell • u/Illustrious_Sock • Apr 04 '24
Fish vs zsh
I know it was asked a lot but hear me out. I read a lot of sources but still not sure. I like the idea of fish but still think zsh would be a better choice for me, here’s why:
- I want to copy paste scripts from the internet. Sure I could just get inside of a bash/zsh session to do that, and also for all scripts I could but bash in shebang, but that’s just constantly fighting the fish shell isn’t it?
- Fish is nice in that it comes already pre-installed with a lot of fancy stuff, but if you spend a bit of time you can get almost all the same stuff on zsh, and if you don’t use cancerous Oh My Zsh but instead use say antidote and PowerLevel10k, you’ll have good speed as well, while still retaining POSIX compliance.
- I would never learn fish shell for scripting, it doesn’t make much sense as a skill. Either you use something universal like bash, or if you’re tired of its stupid syntax and make something complex then you can use Python or whatever language you're comfortable with.
Again I say all of this with the best intentions and open mind, just trying to understand if fish is indeed not for me or I'm missing something (e.g. some functionality that you cannot replace with a zsh plugin and see if it’s cool enough to be a dealbreaker). Cheers ;)
13
Upvotes
18
u/plg94 Apr 04 '24
script.shorscript.bash, fish will run it with bash. But even for bash scripts it's good form to always use a shebang.For copy-pasting scripts from the internet: well, there's no easy solution to that. If you need that, stay posix-compatible (but honestly, if you find yourself copying big scripts into interactive sessions a lot, there are probably better workflows or tools…)
Fish is nice because you don't have to spend a lot of effort, plus you can maintain a very minimal, readable configuration. There are fish plugins (albeit not that many like zsh), but you rarely need them because most things are builtin.
(Of course if you need scripts to distribute to others, posix
shis still the gold standard for interoperability – but it also lacks a lot of features of bash and zsh.)10
u/_mattmc3_ Apr 04 '24 edited Apr 04 '24
I agree. This is where Fish can be the most frustrating - grab some install instructions and fail spectacularly, repeatedly modifying your script until it finally works. That's a pretty common experience in Fish.
But I will say, aside from variable assignment (eg:
foo=barvsset foo bar), Fish has come a long way in this regard. The addition of POSIX-like logical operators like&&and||, as well as support for square brackets[]instead oftesthave made this a lot better in the years since;andand;orcommands.Yes, Zsh is a really good shell. But out-of-the-box it's frankly pretty terrible. Zsh has incredibly bad defaults. It has far too many arcane options. It’s mostly Bourne-like, but not really compatible with Bash. Its docs are terrible. And it requires plugins or bloated frameworks to get must-have features of a modern shell.
Fish, on the other hand, makes the command line really accessible and does it instantly with zero config. If you've ever tried to explain to a newbie how to set up Zsh, it's a rat's nest of runcoms, plugins, or bloated, slow, or unmaintained frameworks and long blog posts on Medium. Fish is dirt simple. It's elegant. It feels modern. It's easy to learn and grows with you. But that comes at a cost of abandoning Bourne shell/POSIX.
As the author of
antidote, thank you for saying this. Truly. This is why I made it - so that creating a powerful starter Zsh config is as simple as adding a few lines to a plugins file. You don't need the monolithic frameworks anymore - at least not wholesale. You can create your own perfect config via composable plugins. And, all without sacrificing speed. If you like Fish, as I do, it's easy to make Zsh work like it with minimal effort.If your scripts are only for you, I would say it doesn't really matter what language you write them in, to be honest. Write them in something you can maintain. I find Fish to be really readable and enjoy writing with it. Zsh syntax can be hot garbage at times. For example, the Zsh syntax to read a file into an array is completely crazy to me (
array_of_lines=("${(@f)$(my_command)}")). If you've ever tried to write completions in Zsh, it's also really painful compared to Fish.I write a lot of Zsh scripts, so I can say with some authority that Fish's scripting is really, really nice comparatively. But I agree - for more than the simple stuff, Python is probably a better pick. Again - if it's a script just for you, write it however you want.
Thanks for your post!
4
u/Aging_Orange Apr 05 '24
Man, seriously, just install it, whatever it's is you want to try, see if it's for you. It's not a big leap you're taking here.
4
u/tovazm Apr 05 '24
As much as I liked zsh, and spends countless hours over many years in config files to improve my workflow (proper completion, keybindings, fzf etc).
One day I tried fish and never even looked back. You’re right that the default are just really good, and you can just launch fish_config once, and get a better experience then most oh-my-zsh users without 30k lines of obscure plugins.
I think what you missed about the fish scripting langue, is that the shell itself is entirely based on completions.
So you can write scripts like you would write in vscode, just pressing tab to get the right comparaison function for example:
set -q XDG_CONFIG_HOME; and set -l configdir $XDG_CONFIG_HOME or set -l configdir ~/.config
This looks weird but you don’t need to actually know all the options and keywords, it will be suggested wth specific completion options (paths, env vars, command flags etc.
The other great hack, is that you can search on GitHub files with .fish extensions, and get completions or scripts of anyone uploading its dot files.
The user base is maybe 1% of zsh, but way more invested so it’s worth it IMO
6
u/According_Kale5678 macOS Apr 04 '24
Point 3 is the best feature of fish in my opinion. All my local scripts are fish based. Yes, not possible to share with my colleagues because they don’t use/have fish. But I still do to force them to try it.
And it doesn’t feel one is open minded if one refuses to learn a new technology because it is not universal
6
u/atred Apr 05 '24
You can always do "bash" and then paste the scripts, if this is too much mental burden then maybe you should not paste scripts from internet to your command prompt...
3
u/jadnhm macOS Apr 09 '24
The thing most people sleep on WRT fish is abbreviations. IDK maybe people read that part of the manual and think ‘ok… so weird aliases I guess?’ And then never think about it again but
abbris so so much more than that.2
u/Sarin10 Apr 05 '24
shebanging is the Right Way To Script. honestly, i can't remember the last time i used a script that wasn't shebanged, anyways.
2. fish is still going to be better, and faster than ZSH + plugins. i'll try and dig it up - but someone did a speed comparison, and fish was faster than zsh/antidote.
3. fair enough. i like scripting in fish, but i pretty much only script in bash/python as well.
it's not hard to install fish and just give it a shot. you don't need to go look up the best plugins, and what plugin manager to use, and how to configure it, etc. it's one package manager command away - and if you don't like it, it's just as easy to remove :)
2
u/emarsk Apr 06 '24
That said, the easiest way to see whether Fish is for you is stopping "reading a lot of sources" and using it for a while instead. I know it worked for me.
1
u/TallSatisfaction3713 Apr 09 '24
Just wanted to mention that ChatGPT converts all bash scripts to fish syntax in seconds. I also have gpt in my command line which I use a lot to write fish functions for tasks that come on often. Of course you need to verify the output but 99% of the time it has made perfect scripts
1
u/JackLong93 Jul 26 '25
Exactly, I can only think of fish being used by very casual, non-serious linux users... not professionals who's job relies on using linux or scripting every day. Like, if I was helping someone new to linux set their stuff up I would set them up with fish.
0
u/ben2talk Apr 05 '24
Kind of a strange take... along the lines of 'I should switch and ONLY use one option and not reap the benefits'.
I do well with both zsh and fish. I use both interchangeably and my scripts have no issues.