When comparing zsh vs fish (Friendly Interactive SHell), the Slant community recommends fish (Friendly Interactive SHell) for most people. In the question“What are the best UNIX shells?” fish (Friendly Interactive SHell) is ranked 1st while zsh is ranked 2nd. The most important reason people chose fish (Friendly Interactive SHell) is:
fish suggests commands as you type, based on command history, completions, and valid file paths. As you type commands, you will see a completion offered after the cursor, in a muted gray color (which can be changed with the fish_color_autosuggestion variable). However, you can NEVER turn them off!
Ranked in these QuestionsQuestion Ranking
Pros
Pro Interactive autocompletion
When you start typing a command, you can press the tab key and it will complete the command you started typing. If there are multiple potential commands, you can choose which one to run by simply pressing tab again. Case-insensitive by default, too.
Pro Powerful community-driven tools via oh-my-zsh
Oh-my-zsh is a community-driven framework, which helps users with their zsh configuration and plugins. 400 plugins, 200+ themes and auto-updates to always be up to date.
Pro Autocomplete for options
Zsh intelligently determines if you are trying to complete a file path or an option, and pressing tab after typing -
will reliably bring up a list of options.
Pro Good bash compatibility
Things you've learned using bash will largely apply to zsh. Scripts written in bash will run with little to no modification.
Pro Safer variable behaviour
Unlike Bash, zsh does not split unquoted variables by default, making it less error-prone.
Pro Recursive globbing
ls **/*.log
for example is supported by ZSH.
Pro Great install procedure
Zsh will take you through a procedure which is roughly 30 minutes in length before during install. Through this procedure it asks you to set different options and customize the shell the way you want it to. Most of these settings are also found in other shells, but to customize them you have to go dig configuration files while zsh allows you to do it in the beginning.
Pro Shared histories
If you spend a lot of time in the terminal, most likely you will have several terminal windows open. Zsh has great support for command line histories. The history is unique and shared through all the different instances.
Pro Smart escaping
Zsh can determine the context of the command you're typing in and determine if it should escape characters if you're typing in a URI.
Pro Pipe output to a temporary file:
Some programs don't support loading from stdin, but ZSH can store outputs to a temporary file, example: unzip =(curl http://example.com/someZipFile.zip)
Pro Faster spelling correction
Zsh' s correct (or correctall) is vastly superior to Bash's attempt at spelling correction.
Pro Auto suggestions
fish suggests commands as you type, based on command history, completions, and valid file paths. As you type commands, you will see a completion offered after the cursor, in a muted gray color (which can be changed with the fish_color_autosuggestion variable). However, you can NEVER turn them off!
Pro Excellent documentation
It has a great tutorial. And the official documentation is clear, full of eloquent examples, and to the point.
Pro Already set up for you
While other shells require a lot of set up to act the way you want them to and to have some useful features, fish works perfectly out of the box. It has all the most widely used features baked in and are there out of the box without having the need to install plugins or tweak any configuration files.
Pro Pretty usable even without plugins
Everything you need from oh-my-zsh is available on default fish, don't need to install any plugins. And even better, fish is smaller than zsh.
Pro Universal variables
You can define Universal variables, which are shared instantaneously through all running fish sessions and persists through shell restarts.
Pro Interactive searchable history
Fish has by far the best way to work with history, everything is automatically searchable. It works in the way you expect. No learning required.
Pro Adding, removing and editing aliases is extremely easy
Pro Creates completion files from manual pages
Fish_update_completions parses manual pages installed on the system, and attempts to create completion files in the fish configuration directory.
Pro Fisherman ⚑ A fast, modern plugin manager for fish
Large test coverage, micro-second shell start, compatibility with plugins from other existing frameworks such as Tackle, Oh My Fish and Wahoo, cache system, offline index, the Fishery and other features.
Pro Intuitive shell expansion in "for" loops
Unlike bash, this won't return you string *.sh if no .sh files are found
for filename in *.sh
echo "$filename"
end
Pro Less ambiguous lists
Here is a sample. Notice that there are 2 files with spaces in names. ls produces a valid list, and for loop correctly iterated through its values.
➤ for a in (ls); ls -l $a; end
-rw-rw-r-- 1 sashka sashka 0 Apr 19 03:16 alma mater.txt
-rw-rw-r-- 1 sashka sashka 0 Apr 19 03:16 whatever i want.txt
sh scripts tend to be fragile when there are lists containing values with spaces.
Also:
➤ echo $PATH
/usr/bin /bin /usr/sbin /sbin /usr/local/bin
➤ echo $PATH[1]
/usr/bin
➤ echo $PATH[-1]
/usr/local/bin
Pro High portability
Because it needs very little configuration to work properly, you can use Fish everywhere. If you are working on a system you don't usually work, installing Fish from the repository is easy and will give you the same experience as the installation on your own machine without having to drag a dotfile around.
Pro Auto indentation when creating functions
When writing functions in an interactive shell, it will auto-indent as needed for if, for, function, etc.
Pro Awesome, consistent, not-confusing sytax
The following, for example:
for file in (find . -name "*.foo" -type f)
fgrep -H "something" $file
echo "hello" $file
end | grep -v "hello"
Will run the for loop, take all the stdout from it (both the fgrep and echo), and then pipe it through the final grep command.
Pro Configuration framework for fish shell
Fish community maintains Oh My Fish, which is a shell framework inspired on Oh My Zsh awesome design and name. It offer a lot of beautiful prompt themes and awesome plugins, is lightweight, awesome and very simple to use.
Cons
Con Not fully compatible with bash
There is a small chance you may have a bash script that doesn't work in zsh, although this is very very rare and most developers will never run into any issues.
Con Requires a lot of configuration to be used fully
Zsh requires a lot of tinkering with configuration files and downloading plugins in order to be able to do tasks which other shells may be able to do out of the box.
Con Defaults are unfriendly for a long-time bash user
Expect to find a configuration you like (or use the configuration utility) to set reasonable preferences. Default zsh interaction is different enough to make you stutter through what used to be familiar workflows.
Con Not POSIX compliant
Being POSIX-compliant may be essential to some, but it is not the be-all-and-end-all. Much of the trouble with POSIX-compliant shells is BECAUSE of POSIX, since it captures the poor behavior and syntax that existed. In most cases, POSIX-compliance is a fool's errand since there are significant differences between implementations of even the same shell (e.g., Bash, etc.) on various platforms.
Although fish tries not to break POSIX compatibility without a good reason, and despite efforts to implement a compatibility mechanism, you can face some issues if POSIX compatibility is expected/required.
Though, enthusiasts fix these cases. For example, add
set shell=sh
in your .vimrc to solve the issue for vim.
Con Doesn't support history expansion ("!!")
Fish has no support for !!
, but you can use Oh My Fish shell framework and install bang-bang
plugin to have this shortcut in Fish shell. The downside of using bang-bang is that it takes over ones default key bindings, for those that don't use them it should not be an issue but for those that do it is an annoyance to be considered.
For sudo !!
, this can also be achieved by making this custom function:
function sudo
if test "$argv" = !!
eval command sudo $history[1]
else
command sudo $argv
end
end
Con Very slow
Much of the functionality in Fish was not written with performance in mind. However, scripting in a shell is not supposed to be about performance. If you need it, use a full-blown programming environment to get it. Shells are for gluing the high-performance tools together.