Bourne Again SHell
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:
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?”
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.
Bash Command Line
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:
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:
The annoying thing about Bash is that freedom looks like this:
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!
101 Bash Commands and Tips for Beginners to Experts
Update 8 July 2019: I recently found this very similar article posted to a French-language message board about two…
Bash Features (Bash Reference Manual)
Bash Features (Bash Reference Manual)
Bash Features (Bash Reference Manual)www.gnu.org