Code Monke #2: Getting to know the Command Line

When I got my first internship as a Front-End Web Developer, I barely knew anything about the command line. I had just finished the JS and HTML courses on Codecademy and the only place that I would edit my code other than the online editor they had on their website, was Sublime Text. I was really scared of the command line. Every time a tutorial would say “now open up the terminal and …” I’d go “Oh $h!t here we go again, black magic starts right HERE…” The command line is that black screen that looks like this:

My current terminal, very spooky 👻

It is where all hackers with hoodies do all of their “hacking” in movies. There’s moving numbers, they’re typing on the keyboard fast, then BOOM the numbers lock onto some random string and they go “I’m IN!”.

Then the tutorial would continue, “Something something Dolla $ign PATH something something comma /usr/local/bin now restart your terminal” … it was a scary world.

Fast forward to about two years later, I got another internship at The FreeBSD Foundation. I had kinda finessed my way into that job, and sold myself VERY WELL at the interview (beyond my capabilities). Little did I know that most of the computers that I was working with at the office didn’t have a window server 😅.

What is a Window Server?

Back in the old days, the only way to interact with a computer was through the command line! There was no mouse, no desktop with cute puppy background pictures, nothing! Just a blank screen that you could type commands into, and receive results back.

As computers became more mainstream, efforts were put into making them more usable! Manufacturers added things like the mouse, windows, clickable icons, etc. to it to make it more “intuitive” to use. They called it the WIMP (Window, Icon, Menu, Pointing Device) paradigm. This is actually where the name “Windows” in Microsoft Windows comes from! It’s this Graphical User Interface (GUI) that allows you to work with a computer.

So for a computer to have a graphical user interface, it should have a Window Server installed. In Mac computers, you can actually see that it’s running in the background! Open up Activity Monitor and you’ll see it:

My Activity Monitor at the time of this writing

Here you can see the WindowServer on the first line at the very top, eating 36.7% of my CPU (that looks high? 🤔). It is the thing that allows my apps to appear as windows that I can move around, resize, open and close, etc.

Back to My Internship at FreeBSD

Most of the computers in the office did not have a Windows or a MacOS. They had an operating system that did not come by default with a Window Server. I had the option of installing a Window Server on them, but I didn’t, and here’s why: Over the past couple of internships, I’d seen some of my more experienced colleagues actually spend most of their time in the command line! They’d write code, run their code, move files around, open applications, do literally EVERYTHING in there!

As scared as I was from the command line, I really admired when I saw someone interact with it so effortlessly. I’d always wanted to try and get more comfortable in the command line, but I never put aside the time necessary to actually do it. This was an opportunity to learn about it and I thought to myself, what better way to do this other than forcing myself to interact with a computer only through its terminal 🤡?

Getting Accustomed

In the first week, it was like hell. I was SUPER slow in doing literally ANYTHING. Navigating through my filesystem, making files, deleting files, writing code, EVERYTHING was painful. I had to do a quick google search on my own personal laptop to perform any task that I wanted to do. The results, however, were glorious :’).

I got DUMMY QUICC 💯💻💨💨

By keeping my both hands on the keyboard, and never actually having to reach for the mouse I was getting much quicker at doing things. I’d found really cool auto-complete tools like fzf and the silver searcher to quickly search through my files. I chose vim as my text editor, and learned to navigate through my code files and edit them. I used tmux to have multiple panes in my terminal (kinda like having multiple tabs on Chrome) so that I could edit my code in one pane, and quickly switch to the other pane and run it.

Doing everything was blazing fast! Opening any application was extremely quick and lightweight because there was no GUI to be opened with it. I was able to do everything much more quickly, plus I was looking cool while doing it! A true hacker 😎.

Me now!

This definitely was a turning point in my career as a software developer. I was no longer shying away from seemingly-technical tutorials, instead I’d embrace them. It truly felt like now I actually understand computers. It also started reflecting in both my academic and professional life. Co-workers were impressed by how easily I could do stuff so quickly, and make modifications and tweaks to my code as I was demoing it to them. Friends also would make comments about how fast I could try things when we were working on an algorithms or a distributed systems assignment together, and it motivated them to learn more about the command line and spend more time in it themselves.

What I use now

Nowadays, even on my own MacBook I spend a considerable amount of time in the command line. I no longer just use vim for all of my editing… I mean there are so many useful features IDE’s provide such as code refactoring, static analysis, debugging, etc. that it would be almost impractical to set up your command line tools and plugins to completely replace them. But I still make heavy use of the command line. I’m still using the same vim shortcuts for my code-editing, and my development experience is basically a hybrid of the two. Here is a non-exhaustive list of the things I use. Each of them deserves a blog post of its own:

  1. vim: it’s a command-line-based file editor
  2. tmux: is a terminal multiplexer
  3. The Silver Searcher: a really fast search tool for your files and folders
  4. iterm 2: a better terminal for MacOS
  5. ideaVim: an amazing vim plugin that works amazingly on all JetBrains IDE’s
  6. zsh and oh-my-zsh: zsh is a unix shell like bash, but together with oh-my-zsh it offers amazing command-completion both in your desktop and in your git projects.

Last But Not Least

Here’s a video of a very smart Monke that is playing pong with his brain and nothing else. My goal as a developer is to use as least physical actions as possible when I’m coding. I got rid of the mouse, the keyboard’s next 💯😤.

I like solving problems, making people laugh, and dancing.