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!
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.
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.
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
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.
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.
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.
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.
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
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.
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.
Because zsh has paid relatively less attention to standards compliancy, it can have more abstruse interactive features one of which is interactive autocompletion.
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.
Oh-my-zsh is a community-driven framework which helps users with their zsh configuration and plugins. It has over 400 plugins, 200+ themes and auto-updates to always be up to date.
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.
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)
There are a lot of distributives available for any architecture, basically you can deploy an appropriate instance to your environment and use it inside your virtual environment. Even inside a limited hosting shell.
There are problems with tab completion not working randomly, keyboard input not being received until hitting enter once, and syntax highlighting breaking occasionally.
Zsh has incorporated features from nearly every other shell. Often without regard for how the feature will interact with existing features. This has lead to a multitude of configurable options that make predicting the behavior of the shell extremely difficult.
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.
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.
Zsh is unfortunately not fully compatible with bash and bash scripts. So in order to have access to some features you have to stick with bash for scripting.
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.
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)
Bash is the default shell on virtually every UNIX system. Making it very portable across different systems and once you get used to it, you can use it everywhere.
Want to run something 5 times? Write a throw-away loop: for i in 1 2 3 4 5; do date; done
If you need it 100 times? Not a problem: for i in {1..100}; do date; done or: for ((i=0; i<100; ++i)); do date; done
How about emailing yourself when remote server is back online? Sure thing: while ! ping -c1 example.com &>/dev/null; do date; sleep 5; done && mailx -s 'server is back!' me@myself.com
By default, there are many built-in features. They make really complex and reliable programs possible. In comparison to dash, for example, you can do the same tasks in less time and fewer lines of code.
alias and set will list aliases and variables in a format that can be run directly with no modifications. Even if the values contain \n.
This is handy if you want to modify a value.
While the manual "page" is nearly a hundred pages long, it is actually surprisingly succinct and stuffed with good information. It is often better than Googling for answers when writing shell scripts. The way it is written makes it easy to stumble upon useful new programming features just by flipping through it .
NOTE: If you find it dense and hard to read at the command line, look for the PDF version.
Vi editing mode works without a glitch. "_" will print you the last argument of the latest command (zsh won't). VI mode is fast off the bat - You don't have to reset any variable (like "KEYTIMEOUT" in zsh) for that.
Bash is licensed under the GNU General Public License ≥3, which gives much stronger assurances that the right to use it can't be restricted.
For example, Microsoft would not be able to claim in court that, even though they've distributed Bash with the GPLv3, a license that explicitly grants people freedom, now Bash is essentially proprietary due to software patents and everyone who uses Bash owes them money. (This may sound ludicrous to those who were not alive when Microsoft tried a similar scheme against Linux fifteen years ago).
The GPLv3 is a license that reflects the genuine ethical issues that arise when people give their time and skills to collaboratively build software. While most people wouldn't insist that their UNIX shell is licensed under the GPLv3+, it does matter and is a big PRO for Bash.
In Bash, exceptions are the rule, not even all being described by the main page.
There are a grand total of 5 different ways of quoting, sometimes even when one does not want to, for instance in command substitutions. These are all based around preserving the literal meaning of every character, with an exception list. There is even an exception list to the exception list in 4 of the 5, regarding how the backslash behaves! The behavior of the backslash is also one of the quoting rules, so naturally, it also has an exception in how it works when it stands before a newline as compared to other characters.
Bash has several layers of interpretations, all to be kept in mind:
The ~ expands to the home of the current user. So if you store it in a variable, can you use it that way? Nope: tilde expansion comes before variable expansion.
Aha, so that's how it works! Then, since applying quotation happens after redirections are set up, it must mean that redirecting within quotes works, right? Nope: there is an exception! If a redirection symbol is not quoted, quotation around the symbol is observed, but is not removed. So, since variable expansion also comes after setting up redirections, and no exceptions are described here in the man page, getting the name of a file from a variable and using it as a target should not work, right? No: redirection does not actually take place when the symbols are being read, the symbols are merely removed and are noted for later, right before when the actual command runs.
Apart from 5 types of quotation, there are basically 2 quoting phases, 2 word splitting phases (with only one being controllable), and a tokenization phase on top of that.
If you have a command, it could be an alias, a special built in, a non-special built in, a symbolic link to a file, a regular file, a function, with different rules regarding how they can be overridden, if redirection happens before or after arguments have been passed (what does "time my_command 2>&1 >log_file" do?), etc.
This list is admittedly long, but it doesn't even scratch the surface of the bloat, complexity and inconsistencies of Bash.
Apple, one of the largest distributors of UNIX systems, only ships an ancient version of bash that predates the iPhone.
No one knows why as Apple hasn't said, but the version Apple includes in MacOS is from right before the license was updated to version 3 of the GNU GPL (General Public License). Other major companies (IBM, Microsoft) have had no problem shipping the latest version of bash, so it's unclear what Apple's lawyers are averse to. The GPL has always said that if you distributed a program, you granted everyone the right to use it freely. The biggest change in version 3 was the addition, "...and that includes software patents."
This was necessary because back in 2006 Microsoft was demanding that any company that uses Linux pay them or get sued for infringing on their patents. They even took some companies, like TomTom, to court. No software which can be restricted retroactively like that is truly free, so GPL 3+ includes a clause saying that if you distribute the program, then you are also granting license to any patents you own that are necessary to run it.
What patents Apple has that bash could possibly infringe on is a mystery, but the bigger question is, Why does Apple even care? So what if they are granting people the right to run bash without being sued by Apple. It's not like they were planning on doing that, right?
Even though it is not bash's fault that it is not Apple Lawyer-approved, this is a CON for it because a lot of people use Apple products. While there are methods like brew to install a current version of bash, Apple does not make it obvious to their customers what they are missing.
One of bash's claims to fame is compatibility with previous versions of itself and historic shells. But, doing that means that new features are often written in tortured, awkward syntax that is not easy to learn. For example, bash uses the POSIX way of doing arithmetic: to add 5+3 you must put the numbers in double parentheses with a dollar sign at the start: x=$((5+3)). It is true that many shells suffer from this same CON, but since bash is such an important shell, it has less wiggleroom to ditch clunky ideas that might break existing scripts.
filename expansion is not consistent. "echo *" will print the names of the files in your current dir, if there are any... and will print "*" if there are none.
What it is mostly used for are file system operations. Guess what it is bad at? Operating on files. It automatically splits and carries out filename expansion on every single string resulting from variable expansion and command substitution unless quoted, by default on whitespace, whilst spaces are very common in filenames.
Before that, it even does pathname expansion, so woe to anywone who does not want to actually operate on files, but has a globbing metacharacter stored anywhere in a variable.
This means what you store in a variable is not going to be what will ACTUALLY be accessed.
If an empty variable is unquoted, it disappears completely due to word splitting, sometimes leading to applications signalling a missing parameter at a wrong position.
If quoted however, said variables cannot be iterated over in a loop, no matter what character one uses for word splitting.
If you use any globbing pattern with a command, be sure to use -- after the option arguments or if none are present, before starting the pattern with a mandatory ./
Otherwise, another Bash script run gone wrong or a hacker can create files named like an option ("-f", for instance) and your program will happily accept it as such, if it results from globbing.
For interactive use, it is convenient. For programming, it is a no-go.
Xonsh uses a syntax which is a superset of Python 3.4 plus some additional shell primitives. Because of the similarity to Python, which is famously an easy to understand programming language, the syntax of Xonsh is pretty easy to grasp too, even more so for Python programmers.
Most parts of xonsh are extensible. You can change tab-completer, prompt, history backend, aliases, functions and pack it to special package (called "xontrib") and put it on Github. The logic are clear and documented well.
Xonsh has one feature that can be considered particularly unique. It stores not just the commands you type, but their output, and doing a search on your history (configurably) can search the output as well.
rc has very C-like syntax, which is very helpful for people who are used to C-like programming languages and will find rc's syntax very enjoyable. For example:
for (i in `{seq 1 100}) {
echo $i
}
In rc $array expands to the whole array and if one of the elements of the array has spaces in it, it's still considered one single element after the array variable expansion.
All variable assignments may optionally specify a type, which will enforce that the supplies value is compatible with that type before storing it, returning an error if there's a mis-match.
The entire Rust ecosystem is known for having excellent, modern documentation, and Ion is no exception. Couple that with it having far less cruft (ie fewer things to learn) some syntactic and conceptual inspiration from Rust, and suddenly you have a very easy to learn (and still very powerful) shell.
There's a number of paper cuts that have yet to be addressed. It's been progressing very rapidly though. Some features have yet to be implemented, some logic bugs have yet to be fixed, and it's not been tested much in the wild. Very early in it's life as of 2017.
Shells written in C are often riddled with memory-based vulnerabilities that lead to high profile security flaws that are continually discovered decades later. GNU Bash's Shellshock vulnerability, for example, is an example of a vulnerability that Rust prevents. Rust raises the bar for minimum code quality standards by enforcing various restrictions on type/variable usage, and therefore Ion provides a high quality code base from the start.
There are no dependencies on C or C libraries (except for the minimum required to run on Linux). By opting for the MUSL target toolchain, a fully static binary can be generated and distributed to systems.
It is exceptionally easy to use 24-bit colors in the shell with Ion's c/color namespace.
echo ${c::0x09F}Bluish text${c::0x630bg}with a brownish background${c::reset}
Offers a unique concept of string and array methods, whereby invoking the name of a method, and supplying arguments to it, you can perform otherwise complex text manipulation at expansion time. Also supports recursively processing the results of method expansions within method expansions.
There's a big advantage to picking a shell which is ubiquitous, since you are likely to work with more than your own systems, and likely want the same or a similar experience there.
A special syntax allows for obtaining values from within special namespaces -- either namespaces that are built into the shell, such as the color namespace, or from plugins, such as the git plugin.
Ion shell is featured within the distributed Concurr application, by the same author of Ion, which creates embedded instances of the Ion shell in the server for executing commands locally.
Dash is way faster than the competition. Even though it isn't good for the interactive shell (because it lacks many features like autocompletion, suggestions, cursor moves etc), it is awesome for scripts.
Dash has a very fast startup, this happens because the shell is started a lot of times during boot and dash minimizes the work it does during this process.
Purely POSIX shell syntax is useful for executing legacy scripts, but the POSIX syntax has a number of shortcomings that negatively effect usability and usefulness. For example, modern day shells need to do more than just execute commands and redirect I/O. They also need to feature first class text manipulation capabilities, and having a clean syntax for scripts increases long-term readability. Performing more advanced text manipulation requires spawning a lot of subshells, which negatively effects the performance of Dash scripts.
mksh is very light on resources it needs to use and as a result it's quite fast. It also gets better results consistently than other alternatives when comparing benchmarks.
The support and number of guides and tutorials is rather limited for tcsh online because there are not many people who use it. At least compared to some of the other more popular alternatives.
NuShell assumes the output should be a structured data from the beginning. It outputs as tables. That helps you to filter, sort and search the output quite easily.
The Bourne shell has always been criticized (most notably by Bill Joy, author of csh) as being unfriendly for interactive use.
It has no tilde (~) expansion. Limited file test operators. Limited math operators.