Bash vs ZSH vs Fish: What’s the Difference?
Video Title: Bash vs ZSH vs Fish: What’s the Difference?
All right today we’re going to learn about bash zsh and fish and what are the differences between all these different shells now a lot of people are confused about this i was for a long time i wasn’t sure what all the different differences there are between all these
So in this video i hope to kind of sort things out give you the pros and cons of each of these different shells why you would want to use each of these and then i’ll get my recommendations as to what you should use but basically i just want to give you
Enough facts to give you an informed decision so that you can decide for yourself which of these shells that you want to use on a daily basis and of course let’s just start with bash so bash to this date is still the default shell on most machines so most linux distributions and most
Linux servers that you’re going to log on to maybe you’re going to ssh into a server it’s probably going to be using bash as the default shell so if you have some sort of job where you’re doing devops or anything where you’re just logging into a whole bunch of different
Machines via ssh or something like that you’re probably going to need to be pretty comfortable with bash because while bash has less features than something like z shell or fish you’re not always going to be able to install these different shells on different machines that you log into so if that
Does describe you if you are going to be ssh into a lot of different things then you are going to want to get pretty familiar with bash even if you want to use something else day to day and before i jump into something like zsh next
I’m going to talk about a whole bunch of different features that zsh has so a lot of features like that you see in zsh let me just pull it zsh here maybe you would have as you can see autocomplete right here or syntax highlighting so it’s highlighting this
Screen for me it’s highlighting some command i don’t have with red and so maybe 10 years ago you couldn’t get any of these features in bash but bash has come a long way and now if you want there are projects where you can install where you can get all of
These and very similar features into bash as well just because i know if i say that zsh has some feature that bash doesn’t then a bunch of bash purists are going to come in here and tell me that actually this feature is available in bash 2. you just need to install this
But i will preface that with saying that using something like zsh is much more configurable and much more extensible and it’s much easier to add on to than something like bash so just as an example if you want to add something like syntax highlighting or auto suggestions like i showed you
Then with zsh you can just add that functionality you can just extend the default functionality that’s already there but if you want to do something like that in bash then you’d have to install this which is basically a replacement for the default bash line editor so whereas you
Can customize zsh’s line editor that is basically this line right here that you type things into so with zsh you can just add on to it and extend it but with bash you just have to completely replace it just because there’s no way to do something like that with just the
Default gnu readline which it has by default but enough about bash let’s actually talk about zsh next so i have zsh right here and zsh is actually pretty similar to bash it just has more features and like i said more customizability so it’s easier to add on to and it also
Has a nice plug-in ecosystem so if you want to add some feature then you would just add some plug-in it can be as simple as just adding a file and sourcing that in your configuration file or you can even install some plug-in manager if you want
To and just have it manage all your plugins for you so adding features to zsh is a lot easier than something like bash and i already showed you a few nice features i had like i have this auto complete right here and i have this nice terminal prompt right here it’ll give me
Get information if i’m in a git repository for example but do keep in mind that none of this is available by default so by default you’re actually going to get a prompt very similar to bash just like i showed you it’s going to have no frills no fancy colors like this
So don’t assume that you’re getting something beautiful like this right out of the box if you do want something like this you are going to have to configure it so let me just open up my zshrc right here and as you can see i have a whole bunch
Of different lines in here i’m adding in a bunch of options here i’m adding a bunch of plugins down here and a whole bunch of other things i’m sourcing the prompt right here and this was basically all manually done so if you do want a nice usable zsh
Experience then you are going to have to customize it pretty much as much as you would with bash but just keep in mind that it is a bit easier as you can see to add these plugins here and while you can use some scripts to kind of set
Everything up for you a lot of people use oh my zsh which sets a lot of this up for you installs a bunch of plugins by default for you you can also use this script that i recommend called zsh for humans which is basically a nice installer for zsh that
Sets up a whole bunch of plugins and things for you i have a video on that if you want to check that out but i still recommend going through and setting up all the configuration yourself just so you have complete control over your zsh and you know what’s going on
But if you’re the kind of person who doesn’t want to go through a whole bunch of configuration in order to set everything up and get it usable then you might not actually want to use zsh so that brings us to our final subject that’s going to be fish so let me close
This out and open up fish right here clear this and as you can see right here by default we have actually a nice little terminal prompt and we have a whole bunch of features that you might find in zsh but without all the configuration so as you can see i get nice syntax
Highlighting and auto complete by default as well as a whole bunch of nice other features so you can go in here and go back and then you can type something in like cd and search through your history with up and down right here so i’m scrolling back to when i cd into
My config directory so that’s useful to find some previous commands if you hit tab you can actually scroll through all these with the arrow keys so the tab completion by default is very nice as well and fish just has a whole bunch of nice sensible default options so fish by
Default just has a very nice default configuration i did not have to do anything to get all the nice features like i did with zsh this all came out of the box so you just install this and this is what you get and bash and zsh are both very old they’ve been around
For more than 30 years so fish is much more modern and so it makes sense that it would have a much more sensible default configuration basically fish just works if you want something that you just take out of the box and everything just works fine then
You might want to check out fish right here now fish is not without its drawbacks unfortunately so fish is not posix compliant and you might have heard that before and you didn’t actually know what it meant so you’re a little bit confused okay fish isn’t posix compliant but is that
Bad do i need to care about that and so let me give you a little example right here so let me go back to zsh for a second clear this out and let’s say in zsh i want to set a variable so i have this variable let’s just say my var
Let’s say i want to make that equal to hello right here so then when i echo out my var right here i’m going to get hello so that’s how you set a variable in zsh that’s how you set a variable in bash and it’s basically the posix standard
Way of doing it so every shot is posix compliant this is going to work in that’s how you set a variable but let’s go back to something like fish so if we’re using fish and we want to set a variable you can say my new var is equal to hi
So we can hit that but it’s not actually going to work as you can see it returns an error right here unsupported use of equals mark and that’s because fish does everything differently just because it’s not posix compliant so any sort of batch scripting or anything that you’re used to say
Setting a variable or making a for loop or making an if statement all of this is going to be in a different syntax in fish so if i want to do this the fish way instead of writing this like this i would actually write set my new var to high and now i
Can echo out my new variable right here and that works as you would expect but if you want to use fish for scripting you’re going to have to learn a lot of things new however that doesn’t mean that you are never ever going to use a
Bash script ever again for the rest of your life so let me just show you uh batch script i have right here it’s going to be dot local slash bin change volume this is just a basic script i have in order to send a notification whenever i change
The volume right here and so as you can see at the top right here this is the interpreter and this is basically which shell is interpreting this right here so this is slash spin slash sh which most of the time is just going to be bash right here
So we’re using fish but we’re still able to use this bash script right here just because we set the interpreter up here so if i want i can of course run change volume up and it’s still going to work as you would expect but of course if we were to
Change this to something like fish and then try to use this then of course it’s going to completely break nothing’s going to work so for the most part you’re probably going to want to continue to keep writing your scripts in bash now that might seem a little bit weird
To you maybe you don’t want to have a different scripting language for scripting and then a different syntax for writing your configuration file in fish for example and you can actually write this in fish but you would have to completely rewrite this script right here using fish’s syntax
And another drawback is that this script is not going to be very portable so if you want to send this script to your friend who also wants to have a change volume notification well you better hope that he’s running fish or it’s not actually going to work and that’s why posix compliance was
Invented in the first place just because it’s nice to have a standard so you can send this to another person also running a unix machine and you can expect that it’s going to basically run the same as it would on your machine so if you want to write scripts and then share them
With a lot of people then i would not really recommend fish but maybe you don’t care about that you just want to write scripts for yourself and you don’t actually care if anybody else ever uses them that’s fine you can write all your scripts in fish shell i
Can’t possibly recommend that but you can do what you want or of course you could just do like i said and then just use a different scripting syntax for writing some bash script right here and then use a different one for configuring your fish and of course you can change that
In dot config slash fish slash slash config dot fish right here but inside the configuration file you would just write this in fish syntax not bash syntax of course so this if statement would not fly at all in bash but it does work in fish so
You do have to keep that in mind that’s what posix compliance means you’re going to have different syntax and fish and if you’re used to working in bash or zsh then porting everything over can be kind of a headache even something similar like aliases are done different in
Fish so you do need to keep that in mind but if you’re the kind of person that doesn’t care about bash scripting that much you don’t really write that many scripts and you don’t mind learning something new in order to configure a little bit maybe you don’t even want to
Configure it that much you are pretty happy with the default configuration then go ahead and use fish but finally let’s get into my recommendations and to what i actually recommend most people to use so i would still recommend most people to use zsh and just set up the configuration yourself i like zsh
Because it is posix compliant so i don’t have to learn some new syntax when configuring it and it’s a lot more easily extensible than something like bash but if you’re the kind of person who’s too lazy to set all that up then i would check out my zsh for humans video
That installation script for zsh or just try fish give fish a shot you can always just try it out and if you find out that you don’t like it you don’t have to use it you can just go back to whatever you were using before and then finally i would just recommend
Using bash if you are working in a whole bunch of different machines that are using bash by default and you just want to be really familiar in bash i would just stick to bash but that’s just a basic crash course onto the basic differences of all these
Obviously i could go much more into detail about all these and explain all the intricate differences between each of these shells but that would be very long i just wanted to give you an introduction if you want to do some more research you can but those are the basic differences
Between all of those and hopefully that makes your decision a little bit easier as to which shell you should use feel free to argue about which one is the best in the comments but that’s all for now personally i’m just going to be over here enjoying my zsh configuration right here
-
Sale!
Wireless WIFI Repeater Extender Amplifier Booster 300Mbps
$29.99$14.99 Add to cartWireless WIFI Repeater Extender Amplifier Booster 300Mbps
Categories: Electronics, Wi-Fi Router, Wireless Wi-Fi Extender Tags: 300Mbps, 802.11N, Amplifier, Booster, Extender, mobile wi-fi booster, Remote, WIFI, Wireless, Wireless WIFI, Wireless WIFI Repeater, Wireless WIFI Repeater Extender, Wireless WIFI Repeater Extender Amplifier, Wireless WIFI Repeater Extender Amplifier Booster, Wireless WIFI Repeater Extender Amplifier Booster 300Mbps$29.99$14.99 -
Sale!
Full RGB Light Design Gaming Headset Headphones with Mic
$24.99$14.99 Add to cartFull RGB Light Design Gaming Headset Headphones with Mic
Categories: Electronics, Gaming, Gaming Headsets Tags: Design, Full, Full RGB Light Design Gaming Headset, Full RGB Light Design Gaming Headset Headphones, Full RGB Light Design Gaming Headset Headphones with Mic, Gamer, Gaming, Gaming Headset Headphones, gaming headset wireless, Headphone, Headphones, Headset, Light, Mic, Package, RGB$24.99$14.99 -
Sale!
Wireless BlueTooth Multi-Device Keyboard Mouse Combo
$39.99$19.99 Add to cartWireless BlueTooth Multi-Device Keyboard Mouse Combo
Categories: Electronics, Gaming, Gaming Keyboards, Keyboard Mouse Combos Tags: Combo, Keyboard, keyboard mouse combos, Mouse, MultiDevice, Set, WireKeyboard Mouse Combo, Wireless, Wireless BlueTooth Keyboard Mouse Combo, Wireless BlueTooth Keyboard Mouse Combos, Wireless BlueTooth Multi-Device Keyboard Mouse Combo, Wireless BlueTooth Multi-Device Keyboard Mouse Combos$39.99$19.99 -
Sale!
High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
$199.99$139.99 Add to cartHigh Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
Categories: Gaming, Gaming Chairs Tags: Adjustable, Chair, computer chairs, Desk, Executive, Gaming, Girl, Headrest, High, High Back Leather Executive Adjustable Swivel Gaming Chair, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar, High Back Leather Executive Adjustable Swivel Gaming Chairs, Leather, Lumbar, Office, Racing, Swivel$199.99$139.99 -
Sale!
Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
$29.99$19.99 Select optionsProfessional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
SKU: N/A Categories: Electronics, Gaming, Gaming Headsets Tags: Cancelling, Gaming, Gaming Headphones with Noise Cancelling Microphone, gaming headset, Headphones, Headset, LED, Light, Mic, Microphone, Noise, Professional, Professional LED Light Wired Gaming Headphones, Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone, Wired, Wired Gaming Headphones, Wired Gaming Headphones with Noise Cancelling Microphone$29.99$19.99 -
Sale!
Gaming Desk with LED Lights USB Power Outlets and Charging Ports
$349.99$249.99 Select optionsGaming Desk with LED Lights USB Power Outlets and Charging Ports
SKU: N/A Categories: Computer Desk, Gaming, Gaming Desk Tags: and Charging Ports, Charging, Desk, Desks, Gaming, gaming desk with led lights, Gaming Desks with LED Lights, Home, LED, Lights, Monitor, Office, Outlets, Port, Power, Room, Stand, USB, USB Power Outlets, White, Workstation$349.99$249.99 -
Sale!
Wired Mixed Backlit Anti-Ghosting Gaming Keyboard
$99.99$79.99 Add to cartWired Mixed Backlit Anti-Ghosting Gaming Keyboard
Categories: Electronics, Gaming, Gaming Keyboards Tags: Antighosting, Backlit, Blue, brown, Gaming, Gaming Keyboard, gaming keyboards, gaming keyboards and mouse, Keyboard, Laptop, Switch, Wired, Wired Mixed Backlit Anti-Ghosting Gaming Keyboard, Wired Mixed Backlit Anti-Ghosting Gaming Keyboards, Wired Mixed Backlit Gaming Keyboard$99.99$79.99 -
Sale!
Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
$119.99$59.99 Add to cartWireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
Categories: Electronics, Gaming, Gaming Headsets Tags: 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, ANC, Audio, Bluetooth, Cancellation, Ear, Earphone, gaming headset, Headphones, Headset, Hi-Res Over the Ear Headphones Headset, HiRes, Noise, Wireless, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Headphones, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headsets$119.99$59.99 -
Sale!
Wired Sports Gaming Headset Earbuds with Microphone
$19.99$9.99 Select optionsWired Sports Gaming Headset Earbuds with Microphone
SKU: N/A Categories: Gaming, Gaming Headsets Tags: Accessories, Earbud, Earphone, Earphones, Gaming, gaming headset with microphone, Headphones, Headset, IOS, Microphone, Sports, Wired, Wired Sports Gaming Headset Earbuds, Wired Sports Gaming Headset Earbuds with Microphone, Wired Sports Headset Earbuds$19.99$9.99 -
Sale!
150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
$49.99$29.99 Add to cart150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
Categories: Charging Stations, Electronics Tags: 150W, 150W Charging Station, 150W Universal Multi USB Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Stations, 150W Universal Multi USB MAX Charging Station, 16 Port MAX Charging Station, 3.5A, Charger, Charging, Fast, laptop charging stations, Max, Multi, Port, Stand, Station, Universal, USB$49.99$29.99
Fish understands that the traits that make for a good interactive shell are completely different from the traits that make a good programming language (or scripting language). It's right in the acronym: Friendly Interactive SHell. Unlike bash which tries to be both a good scripting language and a good interactive shell, fish focuses entirely on being a great interactive shell, and its scripting capabilities and really just for configuring said shell rather than anything else.
Personally I like zsh because I kinda feel like it's the best of both worlds if you're willing to set it up. It also help if you need to work with bash since you need to learn way less differences. I also don't like having two shells bc I feel like it kinda a waste of disk space. But that's a personal opinion and tbh the fishbash combo might actually be more beginner friendly now that I think about it
I use fish + starship, yeah i'm lazy 🤣
zsh is just superior. Unarguable.
Is there a way to implement some of BASH's little conveniences, like
echo ${var[^^|,,|~~]}
into ZSH, instead of having to resort to
echo "$var" | tr ['[a-z]' '[A-Z]'|'[A-Z]' '[a-z]'|'[A-Za-z]' '[a-zA-Z]']
every time I want to change case?
So the shell is a TUI that runs CLIs and TUIs inside it?
Lol fish developers just went and reinvented the wheel. It would be understandable if their approach was more convenient than that in bash it would make sense, but it is less convenient – instead of typing just equals sign you must use the whole command
To be honest, I tend to stick with BASH, because a few hundred machines and a few devs/admins. Buuut honestly, using the command line is just arcane crap at this point. Yes it's often faster, and definitely required for some things, but it's nonsense from 50 years ago.
Correct me if I'm wrong, but I think, in fish, if you add #!/bin/bash to the config, everything after that line may run with bash/POSIX syntax. I haven't actually tried it, I don't use fish, but if you're tinkering it's worth a shot to see if it works.
Also, don't quote me on this, but I don't think zsh is fully POSIX, but they don't break very far away from it so most POSIX stuff should still work. If something doesn't work in zsh, I think there's a specific call you can make to put it in a POSIX compliant mode, though I forget what.
The second part might also just be me misremembering a fish feature as a zsh feature, it's been a hot minute since I found my comfort zone between the three shells so the details are blurring together.
As a last note on my comment, I toyed around with editing my PS1/Prompt line in ZSH when I was figuring out my setup, I came up with this line and have come to really like it, whomever reads this, feel free to steal it for yourself and drop it in your own .zshrc
PROMPT='%F{green}[%F{red}%2~%F{green}]%F{white} 🠶%F{reset_color} '
That line comes out looking like "[~] 🠶", of course with some fancy colors.
And for almost fully fish-like integration, you can download the appropriate plugins to match this plugins line
plugins=(zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting)
That's pretty much everything I do for my own zsh, outside of some aliases and exports.
Can I actually use this on a MAC and so changing the behaviour and output?
Informative video. Thanks!
Eric, this is one of the most complete explanations on the subject, that I've ever seen. You didn't assume that the viewer knew a darn thing about programming and configuring and you concisely cover it so that anyone could understand. Great job!!!
Arr there a fish2bash and bash2fish conversion scripts?
since fish makes some scripts break i use bash as my default shell, but i invoke fish at the end of my .bashrc if it detects that it is in interactive mode
what do you think about powershell? is worth to learn over bash/zsh ?
i should Bash you head for making an unneccasarily long video.
Anyone knows what terminal font that is?
If you only got time to learn one shell the learn bash. You’ll find it pretty much everywhere.
たしか、ZSHって、MacOS標準のだよね。僕はバッシュが好きだ。FF12のバッシュに憧れるから
Zsh FTW 😉
srsly tho – great video explaining the diferences without any bias towards or against any of them – I've been on Zsh for over a decade now and started out with oh-my-zsh as many do to get all the goodies at once – but it became kinda bloated – so I learned to set up my own config and never been happier – I've tried using fish several times but it's so frekin confusing – think I'm just too comfortable with what I'm using 😉
Anyhow – well presented video
Thank you for the straightforward video. Really helped me out to someone who is pretty new to using unix shells.
It's funny that even thou scripts usually start with #!/bin/sh, they may not work with bourne shell (default on BSD) or dash (which is supposed to be smaller and faster), because they wrongly assume that /bin/sh is symlink to bash. And bash is POSIX compatible (it can run sh scripts), but it also adds some simplified, extended syntax, which is not.
Thank you very much i seen this video just in time!
I do the same as Psoewish…….. works well for me too… 😉
Hell yeah that's what I was looking for.
Ok, so here's a comment for the great info from the channel. I tried out Fish from using a basic terminal and I:
– like the features included and not having to do the config myself from scratch (wow, autocomplete is kinda nice),
– hate the fact it's not POSIX compliant (sorry, I like using code from the internet for basic tasks without having to do the conversions, since most of the stuff you'll find won't be for fish specifically).
ZSH 4 humans then, probs.
Appreciate keeping it objective. I was actually looking for "what to know if you're switching from bash to zsh" and every video that popped up was a sales pitch or dunking on bash.
I just use fish as my interactive shell because of how comfortable it is to work with, and then use bash for anything else, including scripting. This seems to be a very common setup and it works really well.
Thanks man, you have helped me today.
I will stick with Zsh for now. 😊
Honestly, ease of modification isn't even a factor in my decision. I don't tend to modify things on the fly. Installing something to get bash tweaked is no more a hassle than installing a plug-in for zsh. I'm more interested in the things that might make a difference in daily operations.
Nushell!
I actually like fish as a scripting language. I think the POSIX standard is odd and makes it easy to write bugs (like if you don't know when to quote variables, or when a process will run in a subshell) and fish fixes these issues by doing saner things by default and removing confusing features (like word-splitting and subshells). I'd love to see fish pre-installed alongside bash in the future so that fish scripts can be considered more portable than they currently are. But something like `sudo apt install fish` is easy to run in the meantime.
I can't be the only one who can't stand typing `"${arr[@]}"` to get all elements of an array, and the "fi" and "esac" and "done" keywords which all do the same thing but have to be used in different contexts. Might as well have added "rof" and "elihw" to be consistent. The standard is just messy and irksome.
YO THANK YOU SO MUCH
1:47 Could you tell me what projects there are for bash which add auto-suggest and syntax highlighting?
At 9:34 you said bash but the shebang is /bin/sh
zsh is just better in my opinion.
in kali 2022 version zsh is the default .
i only learn dont use fish it suck. did not hear any sweet short cuts. why use fish or zsh. bash works? and its allready new from ash= lol
Yesssss, thats what i was looking for. hanks for helping
Fish is best simple and easy to use + you can customize it too with oh my fish.
Personally I use zsh in my terminal, but if I write any scripts it'll be bash. Not sure if this is a stupid reason if the same results can be achieved with a bash shell, but I use zsh because I get features like tab auto completion that allows me to cycle through several results and select the one I want, git status info when entering a git controlled directory and so on.
life and death
Oh arguments. If it's in ZSH but not in Bash, but you can add something to Bash to make it do that, then Bash doesn't have it. Same person making that argument is probably also a bloat Nazi. Sigh.
Very well laid out – thanks! Especially liked the parts about the posix compliance as it really helps me make up my mind about what shell to use going forwards.