DEV Community

Coding Sam
Coding Sam

Posted on • Originally published at Medium on

The Command Line — Your best friend

The command line is a tool used by software developers, to run framework or development tools related commands, run scripts to automate processes and a lot more. If you are learning to code or already code, I think you should not be afraid of the command line. It can seem intimidating at first, but it will improve your workflow.

I met some people that always ran away from anything that didn’t have a GUI (Graphical User Interface). In some cases, you will be just fine. For instance, if you are a C# developer, you will use Visual Studio. Actions related to running, debugging and deployment can be triggered just by clicking in some icons in the IDE (Integrated Development Environment), in this case, Visual Studio. There is nothing wrong with this approach but… When you try to explore other technologies, languages, frameworks, etc, you end up dealing with the command line.

If you are already a software developer, at this point, your reaction should be something like:

https://medium.com/media/0aa640dad9d0aa8f10d4709e424b8bae/href

“What are you talking about? I know how to open the Terminal app on my Mac or Linux or cmd on Windows and run commands in it”.

I am not here to tell you that you must learn how to use the command line… Instead, let me show you, from my experience, how you can have the best command line… Ever!

First, let me tell you how I learned what I am about to share with you. Everything started when I was in a summer internship at a startup. I was a student looking for some kind of real world experience, so I was not really familiar with the command line. The CTO (Chief Technology Officer) showed me how to have a Quake like console (the one that comes down when you press the ‘\’ key in Quake video game) on my laptop that was running Linux. Then, he told me to install oh-my-zsh, which I will talk about later in this post.

Console in Quake game

The CTO is basically the person that is in charge of the technology and engineering departments of a given company.

From that moment, I started to love the command line. Few years later I still use this tool and I am going to share it with you.

Basically, you will need these things:

  • A terminal app
  • Z Shell
  • oh-my-zsh

I will explain what these things are in a moment.

Just follow the two steps below :)

First — Get a nice terminal app

The first thing to do is to get a terminal app. You can use the one that comes with your Operating System but there are better solutions out there, especially for Windows, believe me, you wouldn’t want to use cmd. The goal here is to have a better terminal app with a Unix based command line. Unix is the base system of Mac and Linux Operating Systems. This is why I prefer Mac or Linux, and maybe that’s why you see a lot of developers using such systems. Anyway, if you use Windows you can still get almost the same experience.

Here are my terminal apps recommendations for Mac, Linux and Windows.

Iterm2 running on my own Macbook Pro

Guake running on Ubuntu. Source: https://www.flickr.com/photos/xmodulo/14285529772

ConEmu running on Windows. Source: https://commons.wikimedia.org/wiki/File:ConEmu_screenshot.png

In the Windows, installing just ConEmu will not give you the best experience. You need to install WSL (Windows Subsystem for Linux) and a Linux distribution available in the Windows Store, for instance, Ubuntu.

This will give you a Unix like command line, which is what this entire post is all about.

I think using one of the terminal apps I mentioned before, it is already an improvement… But let’s make it even better…

Second — Make your terminal awesome

I will just show you something that you can install, to have, what I think is the best command line experience possible.

Now, you need to install two things:

  • Z Shell, which is essentially an Unix shell (command line interpreter). The installation will depend on your Operating System. I recommend that you use a package manager. On Windows, if you successfully installed the Linux Subsystem, just use the package manager available in your Linux distribution you are using inside the WSL. If you use Linux, you can just use the package manager of your distribution. On Mac OS, I recommend you to use Home Brew.
  • oh-my-zsh, is a set of plugins that adds more features to the Z Shell. The installation process is just a matter of copy and pasting a command to your terminal. Depending on the installation method you choose, you need wget or curl. Just use your package manager to install one of these two options.

If you made this far, let me show you how awesome this is!

See it in action

Let’s see some examples of cool things you can do with the terminal and oh-my-zsh together.

All the following screenshots were taken from a Mac OS, because I own a Macbook Pro… But if you installed a terminal app and ‘oh-my-zsh’, you will be able to experience the same awesomeness.

  • Plugins

You have a lot of plugins available. Check the complete plugins list and how to install them. Is as simple as add the plugins names to the plugins list in the .zshrc file in your user’s home folder.

https://medium.com/media/80c061172fa043dadb7e68ae287a08c7/href

  • Choose a theme

oh-my-zsh allows you to customize the look and feel of your terminal. I just use the default one, but you are free to give it a different look. Choosing a theme just requires you to define a ZSH_THEME variable in your .zshrc file. Check all the available themes and set this variable according to your choice. For instance, if you want to use a theme named “awesomepanda”, you need to add the following to the .zshrc file:

https://medium.com/media/bdb7a2c906ea7f790c93c9540ccff24f/href

  • Using git

If you use git as the version control of your projects, you know you can use the command line for that. If you navigate to any of your projects folders, you will see the current branch’s name in the right side of the folder’s name. You also have some aliases to make your git commands shorter.

  • git pull => gl
  • git push => gp
  • git commit => gc
  • git status => gst

See this in action…

Using git with oh-my-zsh

  • Autocomplete

Maybe you already know that, when you are typing a command, if you press the TAB key, the terminal will try to complete your command. This is already a cool thing. But… Z Shell and oh-my-zsh take this autocomplete thing to another new level. That’s right, it can help you, for instance, to complete a folder name even if you start typing a word in the middle. If more than one option is available, you can use the TAB key to navigate through the available options.

Autocomplete feature for folders and files

Another awesome level of autocomplete, is related with some software development tools. You have several plugins to help you autocomplete some specific tools commands. For instance, if you work with nodejs, you will use a lot of npm commands, like npm install.

Because you know, developers are lazy, so they will avoid to write as much as possible.

Conclusion

Any software developer has to deal with the command line. Some people don’t like it. Unless you work with a really specific tool set, bad news… You can’t run away from it. I can tell you that, from my experience, it can seem intimidating in the beginning because it requires you to memorize a lot of commands. But… once you begin feeling comfortable, you will love it.

Following two simple steps, you can have a really awesome experience. You just need to download a terminal app for your Operating System. Then, go ahead and install z shell and oh-my-zsh on top of it.

If you are a software developer or thinking about being one, remember…

The command line is as important as any other development tool

Having fun with the command line :)

I talked about the terminal and oh-my-zsh but didn’t go into much detail of the installation process of each required package. That would require a post for each Operating System. The most important thing here, is that you become aware of these tools. Let me know if you would like to read about each OS. I think you have the best experience in Mac and Linux. At my current job, I use a Windows laptop. I came from a Macbook from my previous job, so I was used to a kind of Unix based experience. Fortunately, Microsoft somehow partnered with Ubuntu. This partnership allows you to have a Linux command line in your Windows. Anyway, sometimes there are problems… But I can write about that in a new post.

Share this post with software developers that are in the beginning of their careers or always try to run away from the command line :)

Top comments (0)