# M chipped OSX Development Environment.

## Step One is Install 🍺 Homebrew.

Open a terminal and enter the following commands. If you already have a working Homebrew installed, you can skip to Step 3

```bash
# First, we need to install the basics. You will be asked to enter your password during this process
xcode-select --install 

# After xCode is installed we can install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 

# After succeessful homebrew install it should give you two commands to run 
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

# Now open a new terminal and run brew doctor
brew doctor
```

## Next, Let's Install Some Apps

My personal list of must-have applications is as follows

* [iTerm2](https://iterm2.com) - The best terminal on OSX, period.
    
* [Cheatsheet](https://www.mediaatelier.com/CheatSheet/) - Tells you all the hotkeys the current App has just by holding CMD down
    
* [MyCLI](https://www.mycli.net/) MySQL CLI client with Syntax Highlighting and Autocomplete.
    
* [BAT](https://www.makeuseof.com/bat-an-alternative-to-cat-command/) A syntax-highlighted, searchable, mouse-scrollable version of CAT.
    
* [EXA](https://github.com/ogham/exa) A much better version of LS
    
* [Speedtest-CLI](https://github.com/sivel/speedtest-cli) Run a speed test from your CLI.
    

```bash
brew install --cask iterm2
brew install --cask cheatsheet
brew install mas-cli/tap/mas
brew install mycli
brew install bat
brew install exa
brew install speedtest-cli
```

## Let's Install OH-MY-ZSH and Prompt

```bash
# First let's install OH My ZSH
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

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

# Install zsh-syntax-highlighting using Oh-my-zsh (Preferred)
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# Now add them to the .zshrc plugins
nano ~/.zshrc

# find the plugins and add both of these
plugins=(zsh-autosuggestions zsh-syntax-highlighting)

# While you are in .zshrc go ahead and add the following near the bottom change username with your username. 

if [ -f "/Users/username/.aliases" ]; then
   source /Users/username/.aliases
fi

# Save the file and Open a new terminal tab to verify your ZSH is working.
```

## Installing Powerlevel10k Theme

Run the following commands to install Powerlevel10k

```bash
# gh cli
gh repo clone romkatv/powerlevel10k $ZSH_CUSTOM/themes/powerlevel10k

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

### Enabling PowerLevel10k

Then you need to enable it change the value of ZSH\_THEME to the following in `~/.zshrc` file :

```bash
ZSH_THEME="powerlevel10k/powerlevel10k"
```

### Configuring PowerLevel10k

Make sure your terminal font is `FiraCode NF`.

You can get it at [https://fonts.google.com/specimen/Fira+Code](https://fonts.google.com/specimen/Fira+Code) install the whole family. Using OSX's FontBook. And set your terminal font to `FiraCode NF`

And to configure your prompt run the following command

```bash
p10k configure
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682911878345/e390218f-eb5b-4f39-8c09-2bc35fa7ca08.gif align="center")

Another good prompt I have used for a long time is [Spaceship Prompt](https://spaceship-prompt.sh/) which offers a powerful prompt with very configurable options, but lately, I like PowerLevel10k.

## Let's add iTerm2's Shell Utilities

iTerm2 has some really useful utilities, so let's add some aliases to make them easier to remember and use.

First, I suggest reading the [Iterm2 Shell Utilities](https://iterm2.com/documentation-utilities.html)

After that, let's add some aliases to our aliases file. I always create a `.aliases` file in my home directory and include it in my `.zshrc` I suggest leaving this file open in your editor.

```bash

## IMG CAT Alias 
alias icat="imgcat $1"
## LS with Image Previews
alias ils="imgls"
## Copy to clipboard
alias icp="it2copy $1"
## Download from SSH to your Downloads folder
alias idl="it2dl $1"
## Upload Filename through SSH 
alias iup="it2ul $1 -c -z -v -f"
```

## Let's add syntax highlighting to `Nano`

Now let's spruce up `Nano` with some syntax highlighting by running the following commands in iTerm2.

```bash
# install nano from homebrew
brew install nano nanorc

# update your .nanorc file
echo 'include "/opt/homebrew/share/nanorc/*.nanorc"' >> ~/.nanorc

# Close and re-open your terminal, and you'll have syntax highlighting
```

## Now let's fix up Quicklook real quick and add some features

Let's add Quicklook plugins to make Quicklook more useful. The plugins installed have the following usage.

* `qlcolorcode` - Preview source code files with syntax highlighting
    
* `qlstephen` - Preview plain text files without or with an unknown file extension.
    
* `qlmarkdown` - Preview Markdown files
    
* `quicklook-json` - Preview JSON files
    
* `qlimagesize` - Display image size and resolution
    
* `suspicious-package` - Preview the contents of a standard Apple installer package
    
* `apparency` - Preview the contents of a macOS app
    
* `quicklookase` - Preview Adobe ASE Color Swatches generated with Adobe Photoshop, Adobe Illustrator, [Adobe Color CC](https://color.adobe.com/), [Spectrum](http://www.eigenlogik.com/spectrum/mac), [COLOURlovers](https://www.colourlovers.com/), [Prisma](http://www.codeadventure.com/), among many others.
    
* `qlvideo` -Preview most types of video files, as well as their thumbnails, cover art and metadata
    
* `syntax-highlight` - Preview many different source code files
    

```bash
brew install qlcolorcode qlstephen qlmarkdown quicklook-json qlimagesize suspicious-package apparency quicklookase qlvideo

brew install --cask --no-quarantine syntax-highlight

# To get plugins working in Catalina, you will need to remove the quarantine attribute.
#Run this to see the attributes:
xattr -r ~/Library/QuickLook
#And run this to remove the attributes:
xattr -d -r com.apple.quarantine ~/Library/QuickLook
```

## Let's add allow using our thumbprint to sudo

```bash
# First open the following file with sudo
sudo /etc/pam.d/sudo
# Add the following line at the very top and save
auth sufficient pam_tid.so
# Finally run this command 
defaults write com.apple.security.authorization ignoreArd -bool TRUE
```

### Fixing iTerm2 to allow using the thumbprint

The default terminal works like a charm, but **iTerm2** needs an extra configuration. Go to `Prefs -> Advanced -> Allow sessions to survive logging out and back in` and set the value to `no`.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682906987323/52f0bd72-3b57-46f6-929f-f0036bd6303b.png align="center")

Now logout and back in, and both the default terminal and iTerm should allow using the Thumbprint instead of entering a password when `sudoing`

## Adding more Aliases for EXA and BAT

If you kept your `.aliases` file open, then add the following aliases. Otherwise, reopen it and add the following aliases.

```bash
## Alias to make LS look like this
alias ls="exa --icons -lh"
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682907724941/e3c6142a-3520-4f36-8f27-ae64d922be7d.jpeg align="center")

Now my prompt at the bottom is set up using Power10k, but you can see how it adds icons to the different file types and such.

While you have the `.aliases` file open, let's add a few more aliases I find useful.

```bash
# Copies you public key to your clip board
alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> Public key copied to pasteboard.'"
# Stat Provides a Nice looking CLI Stats 
alias sstat="macchina"
## I use VSC Insider, if you don't use Insiders you dont need this
alias code="code-insiders $1"
## Reload apache
alias rapache="sudo systemctl reload apache2"
# dump autoloader and optimize autoloader
alias cda="composer dumpautoload -o --dev"
# bulk association again if you don't use VSC Insiders just put code
alias -s {md,css,php,js,json,html}=code-insiders
```

`macchina` or the alias `sstat` will render a CLI CPU Stats that looks like this

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682909661501/b8cae4bf-3a67-4965-96ad-e3af1da5b38c.jpeg align="center")

## Using BAT, the CAT replacement

Sometimes, I like CAT to grep it and find specific things. Other times like log files, I want to be able to search and use the mouse to scroll through it, like this. It offers search and mouse scrolling and a lot of other commands.

If you can't figure out how to exit, it's like `Vim` type`:q,` but there are other commands you can use with`:` I suggest reading the docs on BAT.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682909940845/07c78fb7-eb1b-4b55-921c-1a52bf7f136e.jpeg align="center")

I have some more tools, but this article is getting pretty long, so stay tuned for the following article, which will expand on this one.
