by emilecantin · 5y ago · 0 comments
The single best improvement to my command-line workflow I've done in the last few years has been switching shells. First I moved from Bash to ZSH, but about 2 years ago I switched again to Fish.
Why I love it: - history completion searches by default, so I can just type part of a command, hit arrow-up and look through only the relevant results (ZSH also did this, but Fish is better)
- tab completions are shown to you in advance (in light gray in front of your cursor)
- Basic configuration (which is good enough, honestly) can be done via a web browser. Just run "fish_config", and it starts a web server, pops open your browser and any changes you make there are saved to your actual config files. No more looking up syntax.
- aliases (which are called abbreviations) are actually expanded after typing, so the full command appears in your history. You can also edit the full command before running it, if you need.
What about bash one liners?
I had a bad experience with Ubuntu's (Debian's) dash shell many years ago and I've (lazily) just stuck with bash since then.
For me, yes I still write my scripts in hashbanged (ba)sh scripts; the only fish I write is my config.fish. Fish might be an objectively better language, I don't want to learn it and prefer keeping writing (ba)sh, as
1. (ba)sh is an evil I know...
2. ... that I must know anyway to work on servers (while fish's "utility" is low as used nowhere but around the fish shell)...
3. ... and shellcheck makes it (a bit) less of a footgun.
When I do need to write a bash one-liner, I just run it in bash :) . But it's a once-in-a-blue-moon occurrence, since pipes are the same, and fish added syntax for && and || a few years ago (before that, they didn't exist and you had to use and; and or;), and added support a few months ago for `FOO=bar ...` direct env.var setting (before that you had to `env FOO bar ...`). So, your typical `thing --blah | grep stuff | awk stuff | whatever && something` generally works in fish.
* do you have any trouble running shell scripts?
Nope. fish will run bash for most shebangs.
* What about bash one liners?
You will have to translate these.
You can still type "bash" to get bash.