Fish shell
fishshell.com
fishshell.com
However, I just really like fish. I also live out of my own shell, and I don't spend much of my life remote-ing into other machines. When I do, my mind flips into bash just as easily as I flit from TypeScript to C#. To me, this is largely a non-issue, aside from when I need to work out how to set the `$SHELL` variable for a program that expects bash.
No other machine I connect to has fish, but for my own machines, it's my top choice. Still, I write a lot of utility scripts in bash for the compatibility and it can be annoying when I copy a command and I know it won't work because it uses some unsupported syntax in fish. Every now and then, and it is rare, I switch to bash locally to run something.
I can, because whenever I get access to a new machine I download and compile it!
Biggest tip for fish switchers: set fish as your terminal's shell instead of changing your login shell.
That's an interesting idea - I will try that. This bit me recently when I used Migration Assistant to move from a Mac with Catalina to one with Big Sur; my login shell was still set to the path for fish installed via Homebrew, but none of those packages were copied over. I managed to hack around it by copying bash into that location so that I could reinstall Homebrew and fish to finish repairing things.
By default your terminal program uses that, but most terminals let you override that to be something else.
Perhaps not having to run chsh on a new machine, which I have to run -h on to remember how to use ever few years.
Being new increases the chances of doing something like that that breaks the shell. It's annoying to fix for those of us with experience, and extremely difficult to fix for those without experience. It gets even worse when you consider that some distros like Ubuntu don't set a root password, so you can't log into the root account without sudo, which requires your user to have a functional login shell. I wouldn't want a new user to paint themselves into a corner where the only way to get their desktop working again is to remember how to boot into single user mode or boot from removable media and mount their hard drive. Doubly so if their Linux desktop is their only PC; it's going to be really annoying if the only way to write removable media to boot from is the machine that's currently broken.
You can use Fish on any system where Nix runs on, btw. For example, I use it on Synology's DSM.
In bash, I can run the following do the following, and the only ways I found to do this in fish are using several commands or calling `bash -c` with a subcommand.
```
(cat file_1; cat file_2 | grep something) | sort
```
begin; cat file_1; cat file_2 | grep something; end | sort
(note that this is distinct from a "subshell", which has a separate environment and typically is more confusing than helpful. In this particular case it doesn't matter)And FWIW, those 1% environments don’t look and exact exactly like my local system, where I have a nice prompt configured and there are lots of aliases and functions I use frequently. My local bash is nearly as different from my remote bash as my fish is from bash.
I use fish most of the time as a shell, but I still write bash or even sh scripts, because fish is not installed on most systems. If you run a bash script from fish, it is still executed by bash (because of the shebang).
That point appealed me most. If I continue have to use bash for scripting, I wonder what fish provides over zsh.
Even though it's "sane", I would say it's not "powerful". It's significantly less powerful than bash, e.g. there is a list of missing things here:
https://github.com/pirate/fish-utils/blob/master/README.md
The first one seems like one of the bigger issues: https://github.com/fish-shell/fish-shell/issues/159
I have a particular viewpoint since I'm writing a shell for scripting, and I wrote this FAQ. http://www.oilshell.org/blog/2021/01/why-a-new-shell.html#wh...
But I didn't come up with that list of issues, and I've only used fish a tiny bit.
set file_contents (cat filename | string collect -N)
I understand that this is purely anecdotal, but I'm using fish for quite a long time, I've written a lot of tooling for myself in fish, and I agree that sometimes there are some things which are annoyingly missing from fish (like this multiline variable thing), but I would not say it makes fish significantly less powerful. And these things are sometimes fixed, too.I think their "sane" scripting is more about ux for writing short disposable logic (the type you write in a terminal), rather than more detailed/advanced/structured programming that you might save to a shell script file.
Bash/zsh walk the line of being usable enoughh for typing terse quick commands (terminal syntax) while also being complex enough for writing large scripts (programming language). They end up being imperfect at both.
# only test if the build succeeds
./build.py && ./test.py
didn't work in fish until recently. It used to be 'and' but they recently added && for compatibility.I think redirects and possibly pipelines work differently in fish too, although I don't remember the details. I type those on the command line frequently. I occasionally use loops as well, though when it gets big I do put it in a file.
echo hi > out.txt
echo append >> out.txt
sort < stdin.txt
ls /bad 2>&1 | tee out.txt
But here docs don't work the same way: sort <<EOF # syntax error in fish
I don't really like the here doc syntax so I guess that is pretty good. The && issue is still there on my Ubuntu Bionic machine: fish: Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.
ls && lsvim (ls -lh | psub)
Only more recently have I really realised this never applied to 99% of my (most people's?) use-cases.
The logical step many people miss is that shebangs make the compatibility of the user's shell largely irrelevant: the only real compatibility concerns are the bash version or `sh` aliasing on the user's system.
e.g. making bash scripts compatible with current macOS systems (outdated bash version and bsd-ish non-gnu binaries) is a far bigger pain than any compat issues fish brings.
every time someone asks "how do i accomplish X task on the command line" (witness literally thousands of Stack Overflow posts like this) the answer is in bash.
so, i say it applies to essentially every use case where you didn't already know how to do it.
I love fish, but the fact that every answer to your questions is written in another language and has to be translated affects EVERYONE.
I don't get this argument: The solution is to search for:
"how do i accomplish X task in fish"
This is what I do with xonsh.
Of course, the bigger point that is being missed is that when someone opts to use a shell like fish or xonsh, they're less likely to search how to do X! The reason they picked another shell is often because it is easier to use, etc. In the case of xonsh, it's mostly just Python. I do a lot more in it than I could do in bash, because I don't need to search the Internet for anything.
Occasionally you'll need to write the command substitution or command chaining in a different way, but once you get over the initial learning curve this is easy and pretty mechanical.
Very rarely I find some command that just doesn't work in Fish, in those instances it's easy enough to open the bash shell or throw it into a script file.
Those answers, imo, come in 3 forms:
1. Short simple bash commands that will work in fish
2. Overly clever "one-liners" that would be better as a script
3. Edge cases.
(3) is rare enough that I don't see it as a big enough hurdle to avoid using fish.
It's a huge problem if you have stuff that is expected to be sourced into the shell rather than executed as a script., for example, because the sourced stuff provides a large API of functions.
The only exception to this that I see regularly is shell installers auto-adding some directory to the PATH env by making automated changes to bash/zsh confs in $HOME. This may be a slight annoyance for some, but tbh I like it as having to manually paste in a PATH addition myself allows me to audit them (and it's still quick enough).
This drawback is also its advantage, as it doesn't need to repeat all the Bourne-ish problems. (You seem to like this :-), just pointing it out for the others.)
I think people who are interested in how they use the command line will not have a problem to learn two shells, fish for the personal use and something Bourne-ish for scripts that might run on other machines, or by other users.
Things I think are big problems:
* Needing to quote practically everything
* Needing to remember if/fi, case/esac, while/do/done, for/in/do/done, etc.
1) Use fish interactively, with quite a few aliases.
2) Write <= 10 line scripts in sh, perhaps with a bashism if it is very helpful, and only run on my machine.
3) Write > 10 line scripts in Python.
Now that's out of my system, fish is fantastic and made me realise importance of sensible defaults. I tried zsh but configuration took longer than I would have liked, and oh-my-zsh is too bloated to start instantly.
Compared to that, I have practically 0 modifications in my Fish config, apart from few aliases. I don't use fish for more than one-liners, and I never intend to. It is a very nice very fast and very lightweight way to interact with my system, which I believe was the original point of Shells in general.
Either way, glad to see it on frontpage.
Isn't this a common trope with software e.g. "WINE is not an emulator" or people saying "ATM Machine".
Edit: I'm wrong about WINE being a backronym, but it is a recursive acronym.
How is it incorrect?
Which is annoying to those who value form more than function.
DVD disc
LCD display
We like our nouns to be general, and rather turn the acronym into an adjective. It makes good sense too: PROM memory, BluRay disc, OLED display show their connections
"PIN number" is easier and faster to understand. Probably better understood than "PI number" or the expanded form. And in this case, a link just named "fish" would have been fairly ambiguous.
GNU: GNU's Not Unix
The one closest to me (though I didn't invent it): JACK - the JACK Audio Connection kit.
GNU Operating System -> GNU's Not Unix Operating System
Fish Shell -> Friendly Interactive Shell Shell
One expands to include the original acronym, but doesn't duplicate the descriptive extra words. The other doesn't expand to include the original acronym, but does duplicate the descriptive extra word.
In other words, one is recursive but not redundant, the other is redundant but not recursive.
For example, even within a computing context, saying "Fish shell" just might help someone understand that you're talking about the Unix shell and not the cipher, and would always help someone who's not familiar with Fish to at least understand that you're talking about an alternative Unix shell.
By contrast, whenever someone posts a Hacker News article about ML, the first comment is invariably someone complaining that they thought it would be about machine learning, and this is unnecessarily confusing, and a borderline injustice, it should change its name, etc. It would probably be easier for everyone involved if it were idiomatic to say "ML language", even thought doing so would be redundant.
Isn't it funny how the mind works?
I wrote so many more small scripts for myself. Since I didn't need to consult a syntax manual every, the friction was low.
If I need to script something, I always do it in bash (which is easy to transition to from bash). I don't use the fish language for any scripting because of incompatability, but as a command line interface to my systems it has been a massive boom to my quality of life. I could not reccomend it more.
Did you mean dash?
The fact the syntax diverges from bash/zsh is IMO a great boon to fish. I've enjoyed writing fish scripts much more than zsh/bash scripts.
At work I write both for things that runs on dev machines, since I converted a lot of colleagues to fish, and writing the bash/zsh ones is usually not that much effort to write.
Sure, it's a bit of a maintenance burden in theory, but it's not become a problem in practice yet. A few times I had to wonder "how do I sensibly do this in bash/zsh" when it was pretty friction-less in fish, but it hasn't happened often.
Another thing regarding compatibility: I've never had it be a major problem when things _truly_ were incompatible, since as others in the thread mentioned, I could just do `bash`, run the script and then CTRL-C.
- jorgebucaran/fisher (plugin manager)
- IlanCosman/tide (prompt)
- jhillyerd/plugin-git (git abbreviations)
- PatrickF1/fzf.fish (history finder, and other autocompletion)
- jethrokuan/z (directory jumping)
- jorgebucaran/autopair.fish (auto-complete quotes)
The auto-complete experience is what I like most about Fish, followed by abbreviations (not aliases) auto-expansion.
Fish + oh-my-fish + theme-bobthefish + powerline modified fonts
One of Fish’s features I like the most is a per-directory command history stack, on top of the normal history stack.
I’ve used Fish for years and always suspected it offered command history by directory. Fish really “just works” so I never felt the urge to investigate and verify my suspicion.
For me this was vim. After struggling for many years with this ancient and difficult text editor peddled as the holy grail of productivity one day i just said fuck it and switched to a more sane text editor called nano. My life became instantly better and I've never looked back.
I really wish I made the switch earlier instead of suffering through the never ending annoyance of vim because i at the time I thought i was still learning it and one day it will all be worth it.
It's easy to configure zsh to be mostly like fish. Here is my zsh setup, I don't use any zsh framework, just install them with my package manager and source related plugins in $HOME/.zshrc.local (except powerlevel10k which I need to clone the repo and source powerlevel10k.zsh-theme)
- grml-zsh-config[1]. lots of useful base stuff
- zsh-completions
- zsh-autosuggestions. fish-like autosuggestions
- zsh-syntax-highlighting. syntax colors
- fzf-key-bindings.zsh / skim-key-bindbings.zsh. fuzzy file/history search
- powerlevel10k. fancy prompt
e.g. `abbr --add --universal -- gg 'git log --graph --oneline --all'`
I really enjoy it. Faster than zsh once it's loaded with all the plugins that make it behave like default fish.
Definitely, and it's noticeable.
> once it's loaded with all the plugins that make it behave like default fish
Fish also feels more cohesive in this situation; a case of built-in features being more refined due to being under the purview of maintainers and shipped to everyone.
I've heard people say the same about zsh vs bash but when macOS updated I never even noticed.
If those little copy-paste sh/bash scripts would have worked, I'd still be on Fish.
I actually use this guy: https://github.com/edc/bass
I have read a number of opinions concerned about the portability of fish. Perhaps, my own use case is different, but I have experienced very few compatibility problems.
The most common compatibility problem for me is copy pasting a shell command with `$(...)` in it. Switching to bash and re-pasting is pretty effortless, but this doesn't happen often.
I had a good laugh when I read the title of the website praising to be modern 31 years ago.
It would be great if bash was a little less crap though.
I find it so much easier to quickly throw together a function or a script for whatever random task I want to do in fish than in bash and actually have confidence that it'll work without tons of trial and error and needing to look up syntax.
Last time I tried I had not such a good time. Would love to see a tutorial on how to use it efficiently.
[1] https://twitter.com/search?q=a%20command%20line%20shell%20fo...
If you don't want it, set the variable to empty with
set fish_color_valid_path