DEV Community

Marvin
Marvin

Posted on

The Future of the Terminal

The Unix shell; the power of text-driven commands. Simply out of this world.
You can do anything with it; literally (Okay okay, you can't cook pancakes). From getting a list of last modified files, viewing files without opening them with our friends cat, more or even less.Oh and by the way, less is more.

One moment you hear bash, the next its zsh and before you know it it's oh-my-zsh and they just keep coming.

For those in a slight mess of things, or those seeking to find just how deep this rabbit hole goes, this is definitely for you. There are different types of shells in this beautiful text-driven command world and as a heads up, I'll list a couple of them here.

  1. sh
  2. csh
  3. tcsh
  4. ash
  5. korn
  6. bash
  7. zsh

Let us get into each of these to find out what they involve.

Sh

Hush for the godfather of them all; the template, the first of its kind, the one and only sh; the Borne Shell,named after its creator, Borne. This is the first shell to get into the Unix world. Its path? /bin/sh. Its the boilerplate that allows the listing of directories, the file management navigation and most of the things you are aware of now if using a shell. Is this still used? Yes, absolutely. Despite its age and limited functionalities in some ways, sh is still being used and as such many of the newer shells strive to be compatible with it, seeing as every Unix distro I have seen so far has it pre-installed. This is very common and is known to bring some confusion as to the 'it's not working' problem with Bash whose scripts are sometimes run with $ sh some_random_script. by accident when instead it should be $ bash some_random_script.

So, yes. As the godfather, it earns the right to be valid to this date and will still send satellites to Mars.

Csh

The lost sheep: the csh. It's very similar to the C programming language. Hence the prefix -C. Coming in complete with tab completion. To show you just what this means, try getting into the sh shell and head over to your home directory. Something simple, perhaps getting to your documents(or any other folder name) with tab completion.

thegreencodes@thegreencodes:~$ sh
$ cd Doc  #hit tab key

Enter fullscreen mode Exit fullscreen mode

Nothing happens. The equivalent of being thrown deep into the deep-end.
Despite this bonus point against sh, csh has lots of bugs, left for the end-user to sort out, and hence hardly used for scripting.

I doubt you use it even on your day to day use, but if you do, take a look at reasons why not to . The conversation between the Novice and expert cracks me up every time.

Tcsh

Finally, an improvement of the Csh shell. You'll still need a little background with C but you would have far much less struggle as you normally would with csh. The support for this, however, is limited in comparison to the Bourn Again Shell, as is obvious with the default shell for most Linux distributions. So your question on StackOverflow might not get the traffic you might need.

Ash

Yes, that's right. As in burnt wood ashes. It's just Another Shell. Get it? Ash.
Hold your horses one minute, I'm just messing with you. It's the Almquist shell sometimes confusingly so-called sh for short. (Remember this is a fork).

With opensource, a fork of the popular Bourne shell was made and called the Ash. In Debian based systems, this has been implemented as dash so its a /bin/dash directory. As expected, in most distributions based on ubuntu, /bin/sh is just in the end a link to /bin/dash, so you will not actually be using ash.

Unlike its counterpart parent, this is simple and light. To invoke it, go to your terminal and simply type sh.

thegreencodes@thegreencodes:~$ sh
$ 

Enter fullscreen mode Exit fullscreen mode

Just like that! You'll see the little dollar sign replacing your usual prompt.
Because of its rather small size, it's used in systems that do not use a lot of resources. For instance, if you have a rooted smartphone and simply love the terminal too much to let go, so much so you had Busybox installed, then there you have it; Ash. Simple, precise and light.

This, however, comes with the disadvantage of not having all the nips and tricks up its sleeve. For instance, no completion of commands, or a progress bar to show how far a process is on before it completes (Say you are installing a program). Consider it a portable shell.

Korn

Corn? I mean what? No.. its Korn.

See, David Korn(creator of Korn), went into the lab at one point in 1986 and came out with the best of csh. What makes it stand out is the use of coroutines, regular expressions, speed, command-line editing(using vi mode or emacs style right from the prompt) and debugging.

You might need to install it on your system. More information can be found from their official site.

Bash

The Bourne Again Shell

You got it right, the Bourne Shell, sh came back bigger and better. Just head up and take a look at all the advantages of the previous shells, then bring them here. Of course, don't come along with the pains to the party.

This is the most common of shells, beginning every script with the
#! /bin/bash. From the extensive support as you can tell with this graph in comparison to tcsh, to the flexibility, this will be your best choice of the so far mentioned.
The source code to this can be found here just in case you need to manually enter the details for comparison. Rob made a beautiful repo.

Zsh

Then I stumbled upon zsh, and things got real. I'll place it up front, that this is, in my opinion, the best of them. True to its name, it holds a much similar functionality to the bash shell but with way lots more.

Now we both know that you can create bash scripts, add them to your profile and call a single command to do who knows what. For example:

#say a script that makes child processes do several things in the #background
thegreencodes@thegreencodes:~$ make_babies

Enter fullscreen mode Exit fullscreen mode

This comes with one disadvantage; load time. You see, because your script is external, it needs to be loaded first. So you'll append something like this to your .bashrc

source ./path/to_some/random/goodie/script
Enter fullscreen mode Exit fullscreen mode

If you need the slight kick, that slight jolt when executing, you would rather have a shell that already knows what you are saying. As an example, it supports floating points which, you know what, bash does not.
A simple calculation with the bash calculator :

3.5/2
1
# zsh calculator
3.5/2
1.75

Enter fullscreen mode Exit fullscreen mode

Now combine zsh with oh my zsh and you get cranberry pie. You know how you get the terminal with a prompt showing you whether you are in a git repo without having to write the all well known git status? Something like:

 ~ RandomRepository git:(master) 

Enter fullscreen mode Exit fullscreen mode

Yeah.. that little guy that makes it much more relaxing. Coupled with its 101 plugins, you are bound to get something worthwhile suited just to your needs. As an example; the autojump plugin that lets you get to a directory without typing out its full or relative path. Just key in its directory name and walla! I'll leave this bookmark here for you to try it out yourself.

Before we close this for loop of shells, I should mention we also have fish, and (I know.I know I should not make a fish joke) do not get me started on the autocompletion. This is something I have not seen in the other shells. Out of the box. I would place zsh and fish at loggerheads but seeing as I am yet to dive in head to toe with it, I'll be back once my finger muscle memory works better.

In the end, with all these shells in play, the choice comes down to your preference and set up. What makes you feel productive? What are you comfortable using on the fly? This is the million-dollar question even I cannot answer. Well, fam, it's been fun and as I promised, I'm going fishing. Till next time: TheGreenCodes

PS:
Set up a twitter account for all the regular post updates and out of the oven content. You should check TheGreenCodes account out. As always, here to learn, share and grow.

Top comments (13)

Collapse
 
instinct profile image
Instinct

Do you know about Babun (babun.github.io/)?
I have used many cygwin terminals and other linux shells for windows but never found a match for this.
This has pretty much everything. Yes, almost everything just like in linux.

And yeah, can I get some help with linux and bash?

Collapse
 
marvinkweyu profile image
Marvin

Now that's a great project. I've seen the notice for the search of maintainers. I will have to look around for alternatives.

And yeah, can I get some help with Linux and bash?

Details on what you mean?

Collapse
 
instinct profile image
Instinct

I am currently training on RHEL8 (Red Hat Enterprise Linux). I really need the help of a professional who can help me out during problems.

If you may, can we get connected socially on Telegram, Instagram or Facebook?

Thread Thread
 
marvinkweyu profile image
Marvin • Edited

No problem. Send mail.

Collapse
 
moopet profile image
Ben Sinclair

99.9% of everything people go on about as selling points for zsh are there in bash too. Most of the differences are things people don't use that regularly.

Collapse
 
marvinkweyu profile image
Marvin • Edited

You are absolutely right @moopet . In love with bash for scripting 100%.
Zsh is great, but only when you install what you'll actually use. Perhaps those that might get a big plus are the DevOps engineers? What do you think?

Collapse
 
moopet profile image
Ben Sinclair

I don't really see how?

Collapse
 
raguay profile image
Richard Guay

You didnā€™t mention fish. Itā€™s a great shell, but not good at working with bash or zsh scripts.

Collapse
 
marvinkweyu profile image
Marvin

@raguay Having not had the experience with fish, I'd say I'm still knocking on its doors.
From the looks of it, it seems you've been at it for a while? A small heads up about it perhaps?

Collapse
 
raguay profile image
Richard Guay

Okay, I just switched to it and really love it. It is much faster. It also now has a utility you add on call ohmyfish, which does similar activities as oh-my-zsh, but with a very convenient cli utility as well. Also, use the ohmyfish utility to load the bass extension which helps with using bash/zsh files. The scripting language is much more powerful and easier to use. I would highly recommend it!

Collapse
 
raguay profile image
Richard Guay

Really, I haven't used it in a year due to it's incompatibility with nvm for nodejs and venv for python3. But, it works good with all Ruby environment managers. It is fully customizable in a web browser which is easier to use then trying to figure out the right environment variables to set in the correct file (.zshenv or .zshrc).

When I used it, I couldn't get it to work well with Alfred, so I never installed it as my shell, but configured iTerm to launch it. I was actually thinking of giving it another try since it's recently had a major update.

Collapse
 
marvinkweyu profile image
Marvin

Worth it.

Collapse
 
marvinkweyu profile image
Marvin

@citizen428 , Michael, now you talking.