How I set up my Mac
Tags: productivity, beginners, programming, tips
Published: 2021-04-10 23:56:14

**Keep in mind:** some of these steps will be of course optional, such as the iTerm2 installation and configuration. I personally highly suggest the following everything to improve your productivity! If you are at an advanced level already, you can skip all of this.

Let's get started.

## Mac Shortcuts

If you are not very experienced with a Macbook, follow this chapter to discover useful tips!

### Spotlight Search

This will be your best friend. Are you looking for a specific software or folder... or whatever? Press `Command-Space` and start writing what you need. You can even use it as a calculator. Try it.

### Application Switcher

Press `Command-Tab` to open the switcher. If you keep Command key pressed you can use Tab repetitively to navigate through the icons and choose the one you wish to use.

## Terminal

If you never used Linux or Mac before, you probably need to learn how to use a terminal efficiently. Below a list of the most used commands.

| Command               | Description                                                                                 |
| --------------------- | ------------------------------------------------------------------------------------------- |
| `cd`                  | Home Directory                                                                              |
| `cd ..`               | Move to parent directory                                                                    |
| `cd <folder>`         | Move to the specified folder                                                                |
| `pwd`                 | Show your current directory                                                                 |
| `ls`                  | Display files and subdir in the actual directory                                            |
| `ls -la`              | Same as before but detailed with hidden files as well                                       |
| `mkdir <name folder>` | Create a new directory                                                                      |
| `rm -R <folder>`      | Delete folder with its entire content                                                       |
| `rm <file>`           | Delete a file                                                                               |
| `touch <file>`        | Create a file                                                                               |
| `chmod -x <file>`     | Make a file executable.                                                                     |
| `./<file>`            | Run an executable file. Example: `./install.sh`                                             |
| `top`                 | Display info about running processes (similar to Task Manager), you can exit it with CTRL+C |
| `kill <PID>`          | Kill a process using its PID (using the top command, it will be the first column)           |
| `cat <file>`          | Output the content of a specified file                                                      |
| `nano <file>`         | Open and edit a file with the in-built Linux editor                                         |

These are - in my opinion - the basic that you need to navigate easily through the Terminal. There are many other more commands and flags, and if you need a more detailed list, you can always google it.

## What to Install

What do you need to install on your new shiny Mac? Below I will cover what I think any Mac should have, and some are real MUST.

### Homebrew

Homebrew is a package manager. You can use it to install most of the stuff you need, very fast and from the Terminal.

Open your Terminal and copy-paste this command to install Homebrew:

```zsh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

You can now install new software with the `brew install <name>` or `brew cask install <name>` if what you want to install is a graphical GUI application such as our next in the list: Visual Studio Code.

### Visual Studio Code

If you still do not have a favourite code editor, I suggest you give VSCode a try.

You can install VSCode with Homebrew:

```zsh
brew cask install visual-studio-code
```

After the installation, to be able to use `code` command from the terminal, we need to first to install the 'code' command in PATH. How? Open VSCode with Spotlight (`Command-Space`) and press F1 (if you have Touch Bar, press fn and it will appear on it) and type `path`, select the first sentence and press enter. Now go in the terminal and try to open your current folder with the following command.

```zsh
code .
```

Now, have fun customising your new code editor!

### A better terminal

![iTerm2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oww14k8k0lmkz320iw5y.png)

It's time to install and customise iTerm2 and finally get rid of the default Terminal. This process will not only make your Terminal look good, but also improve your productivity with syntax highlight, auto-suggestion and tab auto-complete.

#### Install iTerm2

```zsh
brew cask install iterm2
```

#### Install Oh My Zsh

```zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```

#### Install Powerlevel10k

```zsh
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
```

```zsh
code ~/.zshrc
```

Visual Studio Code will open then set `ZSH_THEME="powerlevel10k/powerlevel10k"`

#### Install Auto-Suggestion

```zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```

```zsh
code ~/.zshrc
```

Now type the following code `plugins=(zsh-autosuggestions)` on a new line.

Close the terminals (Command-Q) and restart it again (`Command-Space iTerm2`) and follow the instructions as per your preference.

#### Syntax highlighting

```zsh
brew install zsh-syntax-highlighting
```

Now add `source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh` at the end of `~./zshrc`

Restart the terminal to apply the changes.

## What's next?

I will write something else in the near future!

Meanwhile feel free to join us in our [ohmyzsh discord](https://discord.gg/ohmyzsh) if you need any help!