Pedro Martin Valera

Installfest

"Installfest" is my personal setup to install applications that I consider essential for software development.

Pre-install

  1. Identify which version of OSX you're using - ideally, you should have Ventura or newer (13.4.x)
  2. Ensure that you've uninstalled any antivirus software you may have, as it can prevent some of the tools from installing properly

Install Xcode Command Line Tools

Xcode is an extensive suite of software development tools and libraries from Apple.

The Xcode Command Line Tools are part of Xcode. Installation of many standard Unix-based tools requires the GCC compiler. The Xcode Command Line Tools include a GCC compiler.

Terminal

  1. Install iTerm2
  2. Set the font size to be 14pt
    • Press + ,
    • Navigate to Profiles > Text > Font
    • Increase the font size

Text editor

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js.

  1. Download Visual Studio
  2. Move the app from the downloads folder to the application folder
  3. Open Visual studio
  4. Turn on Settings sync

Terminal theme

  1. Create a file called one-dark.itermcolors on the ~/Desktop and open it

    code  ~/Desktop/one-dark.itermcolors
    
  2. Copy and paste One Dark theme code into the file

  3. Set the theme

    • Press + ,
    • Navigate to Profiles > Colors > Color presets...
    • Select one-dark

Homebrew Package Manager

Homebrew is a package manager for ~~macOS~~ Linux.

What are packages?

Packages are bundles of source code distributed by developers of software, which can be compiled and installed on your machine.

Install

  1. The package manager allows us to install and update software (like Ruby, Git, MongoDB, etc.) from the command line:
  2. Open http://brew.sh/, scroll down to Install Homebrew and copy+paste the command into the terminal.
  3. Ensure that Homebrew is raring to brew and fix any issues: brew doctor
  4. Update Homebrew: brew update

(Note: the absolute paths will not be used after the next step but might not be needed if they already have /usr/local/bin in their \$PATH)

Zsh

What is a shell?

We will go into more detail about the shell later in the course. Still, a shell is a basic user interface for accessing an operating system's services.

bash vs zsh

Macs before OSX Catalina were shipped with a 'bash' shell by default. Bash stands for 'Bourne-again shell', referring to its objective as a free replacement for the Bourne shell developed by Steven Bourne.

⚠️ If you are using Catalina or a greater version, skip these inside steps ⚠️

We will use another shell called zsh because it has extra features to make our web development easier.

The American English pronunciation of Z is "zee", so Z shell rhymes with C shell, which sounds like a seashell. zsh was also the login of the original developer Paul Falstad's Yale professor Zhong Shao.

Install

  1. Type brew install zsh Type 0 if the prompt asks you about .zshrc
  2. Type zsh . You should have a different prompt
  3. Type exit to return to bash
  4. Type which zsh to determine where your new shell has been installed
  5. Type code /etc/shells and add /YOUR/PATH/TO/zsh. (Lists trusted shells. The chsh command allows users to change their login shell only to shells listed in this file)
  6. In a new tab, type chsh -s /YOUR/PATH/TO/zsh, then close and reopen your terminal application. This will enable zsh by default.
  7. Type echo $SHELL. This should return /YOUR/PATH/TO/zsh

Oh-My-Zsh

Oh My Zsh is an open-source, community-driven framework for managing your zsh configuration. Here is the link to the Github.

The PATH environment variable is a colon-delimited list of directories your shell searches through when entering a command.

  1. Type

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    
  2. Restart the terminal (close and open)

  3. Add the following to .zshrc file to make VSCode the default text editor:

    export EDITOR='code -w -n'
    export PAGER='less -f'
    
  4. Restart the terminal (close and open). The prompt should be a tilde (~), and in colour.

Increase ZSH history

  1. Add the following to .zshrc file to increase ZSH history:

    # History
    export HISTFILE=~/.zsh_history
    ## Increase history size
    export HISTFILESIZE=1000000000
    export HISTSIZE=1000000000
    ## Immediate append
    setopt INC_APPEND_HISTORY
    export HISTTIMEFORMAT="[%F %T] "
    ## Handling duplicate commands
    setopt EXTENDED_HISTORY
    setopt HIST_FIND_NO_DUPS
    setopt HIST_IGNORE_ALL_DUPS
    

Install personal ZSH scripts

Install Starship 🚀

  1. Type

    brew install Starship
    
  2. Add the following to .zshrc to make Starship run on ZSH init

    eval "$(starship init zsh)"
    
  3. To get started configuring Starship, create the following file:~/.config/starship.toml

     # Don't print a new line at the start of the prompt
     add_newline = false
    
    # Disable the package module, hiding it from the prompt completely
    [package]
    format = "via [🎁 $version](208 bold) "
    
    [git_branch]
    symbol = "🌱 "
    
    [nodejs]
    format = "via [🤖 $version](bold green) "
    
    [directory]
    truncation_length = 8
    truncation_symbol = "…/"
    
    [docker_context]
    format = "via [🐋 $context](blue bold)"
    
    [kotlin]
    symbol = "🅺 "
    
    [kubernetes]
    format = 'on [🐳 ($user on )($cluster in )$context \($namespace\)](dimmed green) '
    disabled = false
    
    [rust]
    format = "via [⚙️ $version](red bold)"
    
    [sudo]
    style = "bold green"
    symbol = "👩‍💻 "
    disabled = false
    
    [terraform]
    format = "[🏎💨 $workspace]($style) "
    

Install Bat 🦇

A cat clone with syntax highlighting and Git integration.

  1. Type
    brew install bat
    

Ruby Environment (Rbenv)

A Ruby version manager is a programme designed to manage multiple installations of Ruby on the same device.

Rbenv vs Rvm

There are two main Ruby version managers, Rbenv and rvm. Both have advantages and disadvantages. I use rvm

Note: If a student does have rvm installed:

rvm implode
gem uninstall rvm

Install Rbenv

  1. Install rbenv (the Ruby version manager) and ruby-build (the Ruby version builder) from Homebrew:

     brew install ruby-build rbenv
    
  2. Ensure that rbenv is loaded whenever we open a command line session:

    echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
    
    
  3. Move the rbenv environment higher in the load order:

     echo 'export PATH=$HOME/.rbenv/shims:$PATH' >> ~/.zshrc
    
  4. Quit the current terminal (Cmd+Q)

  5. Then reopen the terminal application, ensuring there are no errors - you should be able to type rbenv -v and get a version number.

Install a version of Ruby with ruby-build

Ruby-build is a rbenv plugin that provides a rbenv install command to compile and install different versions of Ruby on UNIX-like systems.

  1. OS X 10.9 comes with Ruby baked in, but its version is a newer one. We could upgrade that version of Ruby to a newer one, but what if we needed to run one version of Ruby for one app and a different version for another?
  2. Install Ruby 2.2.3. This is the latest stable version of Ruby: rbenv install 2.2.3
  3. This is required every time we install a new Ruby or install a gem with a binary: rbenv rehash
  4. Set the global Ruby to the one we've just installed, which is a sensible default: rbenv global 2.2.3
  5. Test you have the correct version with ruby -v

Skip gem rdoc generation

Whenever we install a gem, it also installs a bunch of documentation we probably don't want - the following command allows us to avoid this:

echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc

Bundler

Bundler manages Ruby gems per-project/application, and makes it trivial to install all the dependencies for an application:

gem install bundler
rbenv rehash

If you install a gem that includes 'binaries' (or any generally available command line scripts), you need to run rbenv rehash so that rbenv can create the necessary shim files, (a shim file ensures there's no threat of incompatibilities between libraries or systems like Bundler and rbenv.)

Install pyenv

pyenv lets you easily switch between multiple versions of Python.

  1. Install
    brew install pyenv
    brew install pyenv-virtualenv
    
  2. Set up shell environment for Pyenv
    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
    echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
    echo 'eval "$(pyenv init -)"' >> ~/.zshrc
    echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc
    

Install python

Check the latest python version and replace the semver number

  1. Install
    pyenv install 3.11.1
    
  2. Set the global version
    pyenv global 3.11.1
    
  3. Python doesn't ship with the most up-to-date version of package manager pip, so upgrade pip
    pip install -upgrade pip
    

Install nvm

  1. Open a terminal window and type:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    
  2. Type source ~/.nvmrc to include the new folders to the current $PATH

  3. Now that nvm is installed, we want to list the available versions, type:

    nvm ls-remote
    
    • And you will be shown a list of all the available Node versions
  4. Install the latest version of node and the current Long term support (LTS)

    nvm install node
    nvm install --lts
    
  5. Check that Node is installed, type

    node --version
    
    • You should see the last version number that you've installed
  6. To use nvm use automatically in a directory with a .nvmrc file, add this script to .zshrc

Install pnpm

  1. Install pnpm

    brew install pnpm
    
  2. Configure PNPM to work globally

    pnpm setup
    

Prettier

Install prettier packages

Install the following prettier packages

pnpm --global add prettier

Install Rust 🦀

Just run this

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Install Git

Git is the version control system that we will use throughout the course. It is one of the most powerful tools you will use as a developer.

  1. This ensures we can upgrade Git more easily: brew install git
  2. Restart the terminal
  3. Ensure you're not using "Apple Git" from the path /usr/bin/git by checking which git and git --version
  4. Configure your name and email address for commits (be sure to use the email address you have registered with Github):
 git config --global user.name "Your Name"
 git config --global user.email "you@example.com"

Git Multiple identities

Instead of having a global user email, we can set a different identity per repo.

  1. Reset global user email

    git config --global --unset-all user.email
    
  2. Set local config per repo

    git config --global --add user.useConfigOnly true
    
  3. Add email to your GitHub account emails

  4. Before the first commit on the repo

    git config --local --add user.email mail@example.com
    

Git set the default branch to be main

git config --global init.defaultBranch main

git show plugin (Delta)

Delta provides language syntax highlighting, within-line insertion/deletion detection, and restructured diff output for git on the command line.

  1. Install via brew

    brew install git-delta
    
  2. Configure git to use delta by adding the following to .gitconfig:

     [core]
         pager = delta
    
     [interactive]
         diffFilter = delta --color-only
    
     [delta]
         features = side-by-side line-numbers decorations
         whitespace-error-style = 22 reverse
    
     [delta "decorations"]
         commit-decoration-style = bold yellow box ul
         file-style = bold yellow ul
         file-decoration-style = none
    

git lb Git alias for recent branches

  1. Paste the following in ~/.gitconfig
[alias]
    lb = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | awk -F' ~ HEAD@{' '{printf(\"  \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}'

git-clean

  1. Paste the following in ~/.zshrc
# Git Remove tracking branches no longer on remote
# https://stackoverflow.com/a/33548037/4842303

git-clean(){
  git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
}

Global .gitignore

There are a few files that we don't want Git to track. We can ignore them by adding the files to a global .gitignore file.

.DS_Store files

.DS_Store files are used by Mac OS X to store folder-specific metadata information. They are different for every Mac, so they often cause conflicts in version-controlled folders.

Since we never want to track. DS_Store files, we can make a global .gitignore file and tell Git to use it for all repositories:

echo .DS_Store >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

public/uploads/, node_modules & bower_components

In the same way, we want to never track the contents of our uploads folder in Rails (which usually contain images or media we uploaded during testing) or our node_modules or bower_components.

echo "/public/uploads/\nnode_modules/\nbower_components/" >> ~/.gitignore_global

autocorrect

Enable auto-correct. The suggested command will run after a short delay to give you a chance to cancel the command if it is not what you intended

git config --global help.autocorrect 20

Configure SSH keys on GitHub

GitHub is a web-based Git repository hosting service. It allows us to keep a remote version of our version-controlled projects. When we push and pull from Git, we don't want to always have to log in to verify who we are. Therefore, we can generate and use something called an SSH key. SSH keys are a way to identify trusted computers without involving passwords.

  1. First, we need to check for existing SSH keys on your computer. Open up your terminal and type:
    ls -al ~/.ssh
    
    Check the directory listing to see if you have files named id_rsa.pub or id_dsa.pub. If you have either of those files, you can skip to the step 'add your SSH key to GitHub.
  2. Generate a new SSH key
     ssh-keygen -t rsa -C "your_email@example.com"
    
  3. You'll be prompted for a file to save the key and a passphrase. Press enter for both steps (default name and no passphrase)
  4. Then add your new key to the ssh-agent:
     ssh-add ~/.ssh/id_rsa
    
  5. Add your SSH key to GitHub by logging into Github, visiting account settings and clicking SSH keys. Click Add SSH key
  6. Copy your key to the clipboard with the terminal command:
     pbcopy < ~/.ssh/id_rsa.pub
    
  7. On Github, create a descriptive title for your key an paste it into the key field - do not add or remove characters or whitespace to the key
  8. Click Add key and check everything works in the terminal by typing:
     ssh -T git@github.com
    

Configure signed commits

  1. Copy your key to the clipboard with the terminal command:
     pbcopy < ~/.ssh/id_rsa.pub
    
  2. On Github, create a descriptive title for your key and paste it into the key field - do not add or remove characters or whitespace to the key
  3. Select the type of key to be Signing Key.
  4. Click Add key
  5. Configure Git to use SSH to sign commits and tags
    git config --global commit.gpgsign true
    git config --global gpg.format ssh
    
  6. Set your SSH signing key in Git with the path to the public key you'd like to use.
    git config --global user.signingkey ~/.ssh/id_rsa.pub
    

Speed up your cursor

During the course, we will do a lot of navigating using our keyboards. By default, the speed of the cursor on a Mac is a little too slow. Let's increase the speed of the cursor by going to:

System Preferences > Keyboard

Move both up to maximum.