10 Must know terminal commands and tips for productivity (Mac edition)
Before I start I have to mention this is heavily inclined towards Mac OS, since we’re going to be installing iTerm2, some commands apply for Linux as well.
1) Let’s start by downloading the shiny iTerm2, I will explain why I chose iTerm2 instead the default terminal.

Alright, we have iTerm2 installed and we’re good to go. Please open your new iTerm2 — I will call it terminal, so keep in mind I’m referencing the iTerm2 not the default Mac terminal.
2) Oh-My-Zsh makes terminal much more user friendly and better. Let’s install it.
via curl
sh -c “$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
via wget
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
If we did everything correctly, this is what we should be seeing

Nice little colours eh? I really love the friendly auto-completion for paths, try navigating to a directory with the help of tab.

Best features I like about oh-my-zsh is the configurability we get. With the default terminal we were using .bashrc
but now we are using .zshrc
config.
Let’s open our .zshrc
and start changing stuff like we want to. I’m going to use my text editor for this
$ atom ~/.zshrc
By the way $
you see here means I’m referencing my terminal.


Now this is where we end up. We can do a lot here, don’t be scared. I’m also using the dracula theme but the default should be robbyrussell. Let’s add a couple plugins for the terminal, like git support, zsh-syntax-highlighting, osx, brew.
Press cmd + F and search for plugins=

Add these couple plugins, save the file and head to your terminal.
We changed our config, but how will zsh
pick up on our file changes? We’ll we can close our terminal and start it up again.. what a time of waste, really. There must be a better way! Well, of course there is my friends, it’s pretty simple actually. It’s called source

This will refresh our config file. Okay the plugins should work now. Allow me to simply demonstrate a couple plugins.
Git support for terminal

Brew autocompletion
If you type $ brew in
and press tab, you should see autocompletion.

Not bad but there is a loooooot of plugins and themes. I’ll post resources below. :)
Themes → Plugins
3) iTerm2 split screening
This is without a doubt the most iTerm2 feature. Actions speak louder than words, allow me to demonstrate what I mean exactly.

Pretty cool eh.
The hotkeys for horizontal split are: cmd + d
The hotkeys for vertical split are: cmd + shift+ d
You can close a window with: cmd +w
Real world example

4) cat
We can peek inside files without actually opening them. Very useful for quick peeks.

For longer files, I suggest using $ less [filename]
5) imgcat
You know that feel when you have two existing image fileslogo1.png
and logo2.png
but you don’t know which is which.
Use $ imgcat
in that case.

6) pbcopy < [file_name]
Copy the file contents to your clipboard, pretty straightforward but very useful! Most seen when copying your SSH
keys.
$ pbcopy < text.md

7) touch
Make a single or multiple files without opening any GUI tools.

8) lsof -i :[port]
View what is using up your current port. Very useful when working with apache, nginx, etc.
$ lsof -i :80

9) Command chaining (&&)
Issue many commands instead typing them out individually one by one.
$ npm i && npm start

10) Open current directory (open .)
Opens current folder in finder.
$ open .

If you want to upgrade your terminal skills to the next level, check the “Classic Shell Scripting: Hidden Commands that Unlock the Power of Unix” book for more.
Thanks for reading, keep learning! Stay awesome! ❤