Bash

Bourne Again SHell

Esther
5 min readJul 26, 2019

When I first started learning to code, I had nothing to do with the the terminal and knew next to nothing about the command line. When I set up my environment for coding school, this is what my terminal prompt looked like:

Again, a year ago I had no idea this wasn’t supposed to look that way on all computers of the land. I didn’t realize that when I installed their gem, they were setting up my environment and consequently my Bash. Fast forward to three weeks ago when I open my new laptop to find this:

Erm… where did my heart go?

I realized there’s a lot going on in my Bash that I just didn’t know about. If you take into account the amount of time I was on the terminal, I’m embarrassed to admit that my first question in all of this was “What the heck is Bash?”

Shell 🐚

Bash is a shell program. The shell is the way in which a user interacts with the computer. Typically, when you want to open a word document, you can click on the icon for the program or click on the folder/file. This is a Graphical User Interface (GUI) which the shell is using to interact with the user. There’s also the Command Line Interface (CLI), which is your terminal and you type in a series of commands to access the word document. Both serve the shell in allowing a user to navigate the computer and its programs.

The way to visualize this is that you have the computer operating system which hold all your programs like Word, Solitaire, Chrome, but those programs are static likes books in a library. You as a user are in search of “Eloquent Javascript”, but it won’t come to you just through wishful thinking. That’s where the librarian or the catalog come into play, the shell equivalent. Both serve the library to allow users to interact with books, the same way a shell serves the operating system in allowing you to interact with its operating system and programs. The librarian (GUI) will pretty much do all the behind the scenes work for you to get you where you need to go. The catalog (CLI), requires that you take a little more control over the tools available to get to where you need to go (knowledge of dewey decimal system, layout of the library, etc) but the power is yours!

Bash Command Line

Bash Features

Bash was created by Brian Fox in 1989 (30 years ago 😲) and remains among the most popular shells used by both Apple and Windows. Some of the features that distinguishes Bash from its competitors include:

  • Aliases : user can dictate what shortcuts they want to use in the command line so I can substitute a long file name with a short string
  • Command history : user has access to see what they’ve typed into the command line and to see
  • Customization of your environment : through their variables, users can create custom prompts like the one pictured above.

The above features aren’t immediately noticeable for a GUI user, but for a CLI user, it can make all the difference.

Why the Command Line?

Let’s dive a little deeper into the command line and why it’s used by programmers. Remember, this is the counterpart to the GUI, instead clicking through images, you’re typing into the command line a series of command scripts that will accomplish the same thing. So let’s follow this task through GUI and CLI.

OK, so let’s say I’m trying to get to a Word document, I double click on the Document folder which shows the Blogs folder. I double click on the Blogs folder which shows me the Bash.doc file. I click on the file and it opens in Word.

OR, I could type open ~/Document/Blogs/bash.doc in the command line! Maybe this isn’t enough to convince you, but as a newb to the command line, this convinced me that while GUI makes the most visual sense, the CLI is an extremely efficient and powerful way of interacting with the computer.

Bash Command Prompt

When you first open a Terminal in your computer it should look something like this:

Bland… so bland…

Assuming you’re like me (as in didn’t know what the Bash was until 48hrs ago from this post), your command line will look colorless and linear. The wonderful thing about Bash is the freedom it gives to users to customize the prompt so that it can look like this:

Oooooh, pretty colors!

The annoying thing about Bash is that freedom looks like this:

\w/T^F\/!!!!

Yea… there may have been an excess of copy/paste action going on with some of that.

Make Bash Work for You

Everyone has their own way of achieving optimum productivity, and as a developer, knowing the capabilities of Bash can make your workflow very efficient and enjoyable. There are many other Shell programs out there in competition with Bash, but they were all created to serve you and to help you use the computer, so open your terminal and give it a go!

Resources

--

--