Bash vs ZSH vs Fish: What's the Difference?

Поділитися
Вставка
  • Опубліковано 23 гру 2024

КОМЕНТАРІ • 349

  • @snuggie12
    @snuggie12 Рік тому +156

    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.

    • @haroldcruz8550
      @haroldcruz8550 Місяць тому +2

      In reality most people go back to bash when the novelty of all of these new cools tools fade away.

  • @Psoewish
    @Psoewish Рік тому +161

    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.

    • @kaitlyn__L
      @kaitlyn__L Рік тому +12

      Yep, I use fish for all my day to day but all except my simplest scripts specify bash. There’s just many more resources for more complex scripts in bash, so why bother translating them into fish if you can just invoke bash in the first line?

    • @BosonCollider
      @BosonCollider Рік тому +2

      I take this slightly further and generally use dash instead of bash for scripts. Dash is literally made to be run as the system shell to run scripts even when the interactive shell is bash, and encourages you to write portable posix-compliant scripts.
      By contrast, fish is kind of suboptimal as a scripting language since fish scripts are not very portable, and tend to be slightly slower than just writing python or perl which are going to be installed on more systems than fish. But it is really nice as an interactive shell. I've tried shells which are supposed to have more features but ended up missing quality of life features like the amazing fuzzy search when you press tab while typing out a file path in fish

    • @m.jamilrahman4971
      @m.jamilrahman4971 Рік тому +1

      I use fish + starship, yeah i'm lazy 🤣

    • @typingcat
      @typingcat 7 місяців тому

      It's not like every system is BASH by default. OpenWrt and Alpine Linux seems to use ASH. So, in either way, I need to use more than 3.

  • @Jeff_Seely
    @Jeff_Seely Рік тому +28

    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!!!

  • @Nevermore101
    @Nevermore101 2 роки тому +36

    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.

  • @bburton333
    @bburton333 11 місяців тому +7

    Great explanation of these shells. One thing many don't understand is it's not necessary to use one kind of shell for everything. For writing simple scripts, I would use Bash or /bin/sh to be (mostly) POSIX compliant. This skill once learned, can be used on any Linux or Unix system with very little deviation. For more complicated scripts I'd use Python, Ruby or Perl, etc. This is true even if my interactive shell of choice was zsh or fish, etc. One exception is it seems Macs now define zsh as the default shell. Even so, for scripting I'd probably use /bin/sh unless there was some feature I really needed from zsh. To put it another way, I probably wouldn't ever write scripts in zsh or fish unless it was for configuring the interactive use of that shell.
    For interactive use, use whatever shell makes you the most productive. If this is your own machine or account that you have complete control over, go ahead and change the default shell but if you have to share an account with others on a server, then leave the default shell and run exec zsh or exec fish after logging in. This is also how you can try different shells without changing the default one.
    I've been using zsh off and on for 30 years and even when I first started using it back then, it was head and shoulders above the ksh shell which was the only other shell that made sense for interactive use on the systems I maintained. I've never used fish but did checkout the docs and it looks nice for interactive use.

  • @BrandonZylstra-jb4jb
    @BrandonZylstra-jb4jb 9 місяців тому +12

    Fish is very nice, and I would have switched to Fish a long time ago, but it would have meant losing hundreds of aliases and functions that I had created over the years for Zsh, so it wasn't worth it. I can't imagine why the Fish creator(s) decided to use such a different syntax. It definitely creates a problem for adoption.

    • @schwingedeshaehers
      @schwingedeshaehers 7 місяців тому +1

      use a script to change the syntax?

    • @typingcat
      @typingcat 7 місяців тому +2

      @@schwingedeshaehers Or maybe just tell A.I. to convert the script. I recently used A.I. to convert my C# code to Python. It had bugs here and there, but it saved me a lot of time.

  • @pavelperina7629
    @pavelperina7629 Рік тому +8

    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.

  • @lVlonkberry
    @lVlonkberry 3 роки тому +41

    This was awesome! Thanks for the detailed explanations in between, this video really covered all the essentials.

  • @dogbyte7875
    @dogbyte7875 2 роки тому +6

    Nice! Thanks Mr. Murphy, for your time and efforts to make this video.

  • @theawesomesandbox
    @theawesomesandbox Рік тому +9

    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.

    • @EricMurphyxyz
      @EricMurphyxyz  Рік тому +2

      That's basically the exact same experience I had using Fish, haha

    • @kaitlyn__L
      @kaitlyn__L Рік тому

      The autocomplete and history search is what sold me on fish, but I do most of the scripts in bash for the second reason. Works fine!
      Now if you’re doing custom bash scripting/programming straight into the command line for one time use rather than running a script repeatedly, I certainly wouldn’t want to switch back and forth all the time.

  • @angeldude101
    @angeldude101 11 місяців тому +2

    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.

  • @SpaceEndeavour
    @SpaceEndeavour 2 роки тому +21

    My login shell is dash and my interactive shell is fish. I find that dash works well with all the stuff my system needs to do and fish works well with me.

    • @pavelperina7629
      @pavelperina7629 Рік тому +4

      What's the difference between login and interactive shell?

  • @FengLengshun
    @FengLengshun Місяць тому

    I ran into the POSIX compliance issue while on an Intro to Python class. It involved running Anaconda, which sets a customized environment for you, and naturally I ran into issues. In the end, I just switched to zsh, and after learning how to fish-ify it, I pretty much never looked back except for my Arch distrobox which runs fish to distinguish the environment for me and bash being set as my login shell to avoid any issues with Nix and the underlying system.

  • @rtothec1234
    @rtothec1234 Рік тому +5

    If you only got time to learn one shell the learn bash. You’ll find it pretty much everywhere.

  • @emil.steiner
    @emil.steiner Рік тому +2

    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

  • @okashiromi5541
    @okashiromi5541 Рік тому +1

    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 fish\bash combo might actually be more beginner friendly now that I think about it

  • @k10_tech_nibba
    @k10_tech_nibba 2 роки тому +4

    Thanks man, you have helped me today.
    I will stick with Zsh for now. 😊

  • @ВладКороль-м2л
    @ВладКороль-м2л 6 місяців тому +1

    It's worth noting fish doesn't exist to be a replacement for Bash scripting but t it was designed aa the usee shell. Look at what it offere interactively like out-of-box autocompletion or sophisticated search history, and how it sacrifices on POSIX compatibility. One more advantage of fish is that it's not inherently tied to Linux or Unix and works the same way regardless OS, which I think is an advantage.

  • @blendernoob64
    @blendernoob64 Місяць тому

    ZSH is the default on Mac OS so I actually been thinking of switching to it on my Linux workstation. I love the autocomplete. However I don’t care about ricing up my terminal. I want my terminal to look like the one in IRIX or the one in Jurassic Park because SGI was so cool.

  • @kmemz
    @kmemz Рік тому +1

    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.

  • @mannedmodule
    @mannedmodule Місяць тому

    What I think you lose by meddling with multiple shells is the speed and productivity that comes with muscle memory when you become lightening fast using one. For that reason, and for portability reasons, I’ll stick to bash. I actually find it frustrating that the MacOs default is now zsh, and I have to hack my terminal to get it working with bash again.

  • @orangemicroprocessing
    @orangemicroprocessing Рік тому +1

    Thank you for the straightforward video. Really helped me out to someone who is pretty new to using unix shells.

  • @Nikolai508
    @Nikolai508 2 роки тому +9

    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.

    • @zeechy
      @zeechy Рік тому +4

      Plus the z makes it sound cool

  • @johnterpack3940
    @johnterpack3940 2 роки тому +2

    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.

    • @EricMurphyxyz
      @EricMurphyxyz  2 роки тому +1

      I mean, in my experience, installing a plugin for zsh IS easier than tweaking bash. However there's not a huge difference between the two besides some small things (like zsh has better tab completion). Feel free to use either one.

  • @mx338
    @mx338 7 місяців тому

    I like the fish had, throwing away the baggage of posix, to a create more friendly shell and scripting language, but they didn't overcome the portability problem.
    I instead write most scripts as a single file python script, since a Python 3 interpreter is present in almost every modern Linux system.

  • @QmiStudying
    @QmiStudying 6 місяців тому +1

    i just use zsh, oh my zsh makes it very easy to add plugins to your configuration. I can't imagine my life without them.

  • @AGSfeel666
    @AGSfeel666 Рік тому +1

    Can I actually use this on a MAC and so changing the behaviour and output?

    • @EricMurphyxyz
      @EricMurphyxyz  Рік тому +1

      On MacOS? Of course. But MacOS uses zsh by default.

  • @CleverBoy0098
    @CleverBoy0098 Рік тому +1

    what do you think about powershell? is worth to learn over bash/zsh ?

  • @vikingthedude
    @vikingthedude Рік тому

    So the shell is a TUI that runs CLIs and TUIs inside it?

  • @justrajdeep
    @justrajdeep 2 роки тому +1

    I could not find your zshrc can you please share it?

  • @johnnyrosenberg9522
    @johnnyrosenberg9522 7 місяців тому

    I was more curious about the difference in scripting, like which one is fastest, some useful features and so on, but I guess there's some video about that too, somewhere.

  • @tropicalverktaki
    @tropicalverktaki 2 роки тому +1

    Just curious, which font is that? Pretty neat

  • @atarg2239
    @atarg2239 3 роки тому +5

    Thanks for video. I'd been searching that difference between them recently. 😄

  • @whylde7834
    @whylde7834 3 роки тому +2

    Smart comparisons! Thanks for the video.

  • @asdil12
    @asdil12 Рік тому

    Anyone knows what terminal font that is?

  • @YERAFirearms
    @YERAFirearms Рік тому

    Arr there a fish2bash and bash2fish conversion scripts?

  • @shimadabr
    @shimadabr 7 місяців тому

    One good thing AI brought us is the ability to easily translate a fish script to bash (and vice-versa). For simple scripts it will do a good job.

  • @ChozoSR388
    @ChozoSR388 Рік тому

    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?

  •  4 місяці тому

    Where is the "zsh for humans" video that is mentined? UA-cam is not finding it...

  • @l-lawliet6174
    @l-lawliet6174 2 роки тому +1

    Fish is best simple and easy to use + you can customize it too with oh my fish.

  • @x0vg5hs1
    @x0vg5hs1 Місяць тому +1

    I use whatever is default.

  • @jullien191
    @jullien191 7 місяців тому

    Con el zsh no hay la documentación en mi idioma. Es solo inglés

    • @ltecheroffical
      @ltecheroffical 5 місяців тому

      What else do you expect? quite a bit of programmers use english

    • @jullien191
      @jullien191 5 місяців тому

      @@ltecheroffical bash tiene la documentación en otras idiomas.

    • @ltecheroffical
      @ltecheroffical 5 місяців тому

      @@jullien191 I know about that

  • @zeio-nara
    @zeio-nara Рік тому

    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

  • @AMathMonkey
    @AMathMonkey 2 роки тому +7

    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.

    • @zobayer1
      @zobayer1 2 роки тому +1

      one main problem with this is that you often cannot sudo.

  • @cim8097
    @cim8097 2 роки тому

    At 9:34 you said bash but the shebang is /bin/sh

    • @EricMurphyxyz
      @EricMurphyxyz  2 роки тому

      /bin/sh is usually symlinked to bash though (sometimes dash, which is also posix-compliant)

    • @cim8097
      @cim8097 2 роки тому +1

      @@EricMurphyxyz sometimes? Never heard of that before. I’ve used Debian, arch, fedora, manjaro, alpine, and other distros but never heard of the sh binary getting symlink to bin bash.

    • @EricMurphyxyz
      @EricMurphyxyz  2 роки тому

      @@cim8097 I'm using arch right now and it's symlinked to bash without any prior configuration. You can check what it's symlinked to with this command in your terminal: readlink -f $(command -v sh)

  • @Doc_playzz
    @Doc_playzz 2 роки тому

    Yesssss, thats what i was looking for. hanks for helping

  • @ubercorey
    @ubercorey 2 роки тому

    Really great for this noob wondering how to get set up to start Dev study. Thank you!

  • @Arsche
    @Arsche Рік тому +2

    たしか、ZSHって、MacOS標準のだよね。僕はバッシュが好きだ。FF12のバッシュに憧れるから

    • @kaitlyn__L
      @kaitlyn__L Рік тому

      It’s interesting that bash is transliterated into kana but zsh isn’t.
      It makes sense, bash is pronounced as a word while zsh is pronounced like initials.

  • @seanpaul7069
    @seanpaul7069 2 роки тому

    Great content and explanation. I subbed :)

  • @Void_Dragon
    @Void_Dragon 6 днів тому

    I just use Fizsh, best of both worlds.

  • @MannyGraal
    @MannyGraal 3 роки тому +8

    I didn't even know about the variable stuff. Lol I was just using my terminal for updating, CDing into folders and normal things. Also writing neofetch to the end of .bashrc for the neofetch command on start up. Wow, Interesting

    • @EricMurphyxyz
      @EricMurphyxyz  3 роки тому +6

      Yeah, if you don't really do any bash scripting, then fish is probably fine. But just something to keep in mind

    • @aronwomack359
      @aronwomack359 2 роки тому +2

      you can add aliases as well at the end, you can do a lot of things just with nano . bashrc, but appending is better, and I always keep a copy of the config file on an external drive, or a cloud, but that's basically the same idea. I keep a libre office document with all the things like bash, zsh, e.t.c. It has came in handy once or twice. Bash is a very powerful thing if you know how to use it, but I have been using fish, and it has a lot of functions too, but it isn't as fast as the others. Alacrity is the fastest terminal emulator I've used, but I still stick with gnome, but have terminator and others that I use. Bash just has so much info, and support groups, anyone can script If they can copy and paste lol.
      You can run math problems easier in fish too, they're all basically the same, just different for whatever hardware and etc. they just interpret their commands into machine code, just have different functions. But, as always, you can edit bash to do anything you can imagine, just gotta know a little Code. And patience, lot of that.

  • @Atif1702
    @Atif1702 3 роки тому +9

    Your content is amazing, Eric.
    Please make a video on different state management libraries (Context API, Redux, MobX, Recoil etc...) and which one is better suited in which scenario?
    Thanks

  • @alexnone
    @alexnone Рік тому

    Thank you very much i seen this video just in time!

  • @0xtz_
    @0xtz_ 2 роки тому +2

    Kali Linux have zsh as a default shell 🐧

    • @EricMurphyxyz
      @EricMurphyxyz  2 роки тому +2

      ZSH as a default shell is pretty good, I have no issues with it

    • @0xtz_
      @0xtz_ 2 роки тому +1

      @@EricMurphyxyz yes try to add OhMyZsh to it 👌

  • @trueriver1950
    @trueriver1950 11 місяців тому +2

    Yawn!!! I hoped for the actual differences, not the availability

  • @lazarusrize
    @lazarusrize Рік тому

    Informative video. Thanks!

  • @jullien191
    @jullien191 7 місяців тому

    你会写脚本吗?

  • @prashlovessamosa
    @prashlovessamosa Рік тому

    Hell yeah that's what I was looking for.

  • @starpawsy
    @starpawsy 5 місяців тому

    And none of them measure up to the Korn shell. AT&T forever !!! LOL.

  • @douglasemsantos
    @douglasemsantos 8 місяців тому

    Great video!

  • @jnankin
    @jnankin 2 роки тому

    great video, but also.... drinking game: every time "right here" is said

  • @m.jamilrahman4971
    @m.jamilrahman4971 Рік тому

    I use fish + starship, yeah i'm lazy 🤣

  • @PeiDeur-w9z
    @PeiDeur-w9z 3 місяці тому

    Kayley Plain

  • @Miguel_GM
    @Miguel_GM 3 роки тому +1

    Thanks.

  • @YankaZabka
    @YankaZabka 2 роки тому

    Thanks for this useful video!

  • @jullien191
    @jullien191 7 місяців тому

    Muy bien amigo. Estoy con bash

  • @StevenLewis-j3e
    @StevenLewis-j3e 3 місяці тому

    Wilhelm Stravenue

  • @osandagg
    @osandagg 2 роки тому

    in kali 2022 version zsh is the default .

    • @EricMurphyxyz
      @EricMurphyxyz  2 роки тому

      It's the default on MacOS too, I think it's a good thing

  • @CharlesXenia-c8z
    @CharlesXenia-c8z 2 місяці тому

    Joannie Extensions

  • @TomAurelio-u3z
    @TomAurelio-u3z 3 місяці тому

    Jakubowski Shoals

  • @KelleyHaley-y7z
    @KelleyHaley-y7z 3 місяці тому

    Boyer Glens

  • @fjonesjones2
    @fjonesjones2 Рік тому

    I do the same as Psoewish........ works well for me too... ;-)

  • @FredLockamy-w9f
    @FredLockamy-w9f 3 місяці тому

    Keebler Plain

  • @HaggaiDominic-p5j
    @HaggaiDominic-p5j 3 місяці тому

    Mitchell Flats

  • @LincolnValentine-k2o
    @LincolnValentine-k2o 2 місяці тому

    Norberto Knolls

  • @manaswinipanda6695
    @manaswinipanda6695 3 місяці тому

    Kirstin Ferry

  • @LynwoodSandlan-f1h
    @LynwoodSandlan-f1h 3 місяці тому

    Roberts Prairie

  • @RamonDrew-d5m
    @RamonDrew-d5m 2 місяці тому

    Ebert Locks

  • @SpenderChad-q8w
    @SpenderChad-q8w 2 місяці тому

    Ladarius Shoal

  • @SpenderBaird-c4o
    @SpenderBaird-c4o 2 місяці тому

    Lindgren Turnpike

  • @KellyUnderwood-v2k
    @KellyUnderwood-v2k 3 місяці тому

    Blake Centers

  • @DanJoshua-j9l
    @DanJoshua-j9l 3 місяці тому

    Jayce Light

  • @AmosZangger-u9h
    @AmosZangger-u9h 3 місяці тому

    Rippin Highway

  • @RobertBrown-i8s
    @RobertBrown-i8s 3 місяці тому

    Hayley Forges

  • @RobertAllen-r6u
    @RobertAllen-r6u 2 місяці тому

    Lindgren Knoll

  • @zer0nool442
    @zer0nool442 Рік тому

    zsh is just superior. Unarguable.

  • @HumeAdair-r2p
    @HumeAdair-r2p 2 місяці тому

    Sheridan Keys

  • @MotleyCronin-b6x
    @MotleyCronin-b6x 3 місяці тому

    Ondricka Wells

  • @FranklinHannah-g9f
    @FranklinHannah-g9f 2 місяці тому

    Josianne Ports

  • @fatcat3513
    @fatcat3513 3 місяці тому

    Play settings : speed 1.75x problem solved🎉

  • @NoONE-bk7ud
    @NoONE-bk7ud 4 місяці тому

    fish has everything i need

  • @LewisJulian-l1e
    @LewisJulian-l1e 2 місяці тому

    Harvey Garden

  • @LucilleRoss-k2v
    @LucilleRoss-k2v 3 місяці тому

    Gutmann Crescent

  • @GenePlummer-u7d
    @GenePlummer-u7d 3 місяці тому

    Christelle Extension

  • @zoefumdajacobson7105
    @zoefumdajacobson7105 2 місяці тому

    Darryl Inlet

  • @vocod3
    @vocod3 2 роки тому

    YO THANK YOU SO MUCH

  • @GingeraWilson-j5c
    @GingeraWilson-j5c 3 місяці тому

    Monahan Ridges

  • @AdinaKennedy-r4v
    @AdinaKennedy-r4v 2 місяці тому

    Hahn Courts

  • @BrendaRita-s9q
    @BrendaRita-s9q 3 місяці тому

    Leannon Inlet

  • @ArchibaldJeremy-z8c
    @ArchibaldJeremy-z8c 3 місяці тому

    Schoen Centers