We will be installing and configuring the following tools to set up your development and classroom enviroments:
- Homebrew - A command line package/installation manager
- zshell - a Unix login shell
- oh-my-zsh - a framework for managing zshell's configuration
- GIT - everyone's favorite content management system
- Vscode - a lightweight and flexible code editor designed for web development (and more)
- If you are using an M1 chip mac, you will have to configure Rosetta 2 for compatibility with apps built for intel chips
We will be using slack to communicate throughout the course. You should've received an invite to our channels via e-mail. You can login via the web browser, but downloading / installing the app is highly recommended.
If you need to install Rosetta 2 you can use the following command:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
The following methods have had the most success for M1 compatibility:
- first try this method which creates a duplicate terminal that runs with Rosetta 2 for compatibility. You should use your Rosetta 2 for most brew installs.
- If that doesn't work try this, which will allow you to install a compatibility mode version of homebrew.
Homebrew is a command line interface package manager that we will use to install various development tools in our class.
Open up your terminal app and paste the following command into it to install homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
If you need to, you can visit the homebrew website for more details.
You may be prompted to install XCode command line tools. When prompted, click yes and your homebrew installation will continue.
After the installation process, run the command brew doctor
. If any warnings or errors are displayed, we will need to resolve them before proceeding with the rest of the install fest.
We do not use Xcode in class but some other applications that we do use require some Xcode libraries. Normally, all you need is the Xcode CLI which should have already been installed when you installed Homebrew. If it didn't get installed, you can use this command:
xcode-select --install
If you need to, you can install Xcode through the App Store. Link here
A shell is a text interface into our computer, and we will be using a lot to run commands.
Zshell is the default mac shell these days, but if you don't have it (or aren't sure) you can install it with the command:
brew install zsh
Don't worry, if homebrew noticed you already have it installed running this command won't cause any problems.
If it prompts you to change your default shell to zsh, select yes! When it asks you for your password, enter your computer user password (it wont show up, but iTerm is keeping track of your keystrokes).
If you are not asked about changing your shell, and you still have a $
at the beginning of your prompt(meaning your shell is still bash), run the following command and then enter your password:
chsh -s /bin/zsh
You can check to see if it worked with this command:
echo $SHELL
Oh my ZSH?!!! We will be tricking out commandline even further with Oh-My-Zsh. When it comes to the terminal oh-my-zsh is the real life of the party. It is used to easily configure the look and feel of your command line.
Copy and past the following command into your terminal to install oh-my-zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Restart your terminal, and you should see a brand new and colorful command prompt.
Before we do this process, please make sure you have signed up for an account on Github. We will be installing a version of GIT from home brew and also configuring it.
We will be installing a version of git from homebrew.
brew install git
after git is installed run the following command to check your git version:
git --version
NOTE: if you installed git with homebrew and are still seeing a version of git that is less than 2.28 run the following command to get the newest version of git.
brew link --overwrite git
If it is anything less than 2.30.0, run the following command to get the latest version:
brew upgrade git
Configuring GIT
Using your email credentials for GIT, run these commands with your user and email configured.
git config --global user.name "YOUR-USERNAME"
git config --global user.email "YOUR-EMAIL-ADDRESS"
git config --global push.default simple
git config --global credential.helper cache
# optional: set the default git editor to be vscode to aviod getting stuck in vim
git config --global core.editor 'code -w'
git config --global pull.rebase true
Setting up Github Personal Access Token
We are going to to use need to generate a personal access token on github that will allow us to interact with github using the CLI more easily.
The official github instructions can be found here directions found here to create a person access token.
Once you have your personal access token, the next time git asked you for your password in your terminal, you can use the token instead to configure git.
First, make sure your gihtub email has been verified.
Once your email has been verified, navigate to the New Person Access Token page and do the following.
- Give the Personal Access Token a memorable name that describes its function, such as CLI-Access-Token
- Click on the expiration drop-down menu and set it to No Expiration
- Scroll down and click every single scope checkbox
- Check that your personal access token looks like this:
Now, click Generate Personal Access Token And you will be take to a page that displays a hash that starts with ghp_. Click the button to copy the hash, and save it someplace safe (such as slacking it to yourself), because github will never show you the hash again, and you will need to generate a new token if you lose it.
Next time you to to push to github, supply this hash as your password to authenticate your computer's terminal.
Currently the most popular editor according to developer polls. This is Microsoft's free version of Visual Studio.
Run the following command to install vscode with homebrew:
brew install --cask visual-studio-code
vscode will appear in your applications folder when the installation is completed
You can also download and install VS Code from here
Adding the code Command to your Terminal
First lets configure vscode. For ease of use, let's make it so we can automatically open up any file or project in VS Code, from our command line. The following instructions are taken from these docs. If you're on a windows or linux, see the left-side menu to switch to the instructions for your machine.
First open Vscode and then open the Command Palette with Shift+⌘+P
. Type type 'shell command' to find the Shell Command: Install 'code' command in PATH
command (it will be the first one that comes up).
Alternatively, you can achieve this functionality by adding VS Code to your path inside your ~/.zshrc file (zshell config file):
NOTE: you don't need to do both
Open your zshell config file with the following command:
open ~/.zshrc
add this to the file path and save:
export PATH=$PATH:"/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
Restart the terminal for the new $PATH value to take effect. You'll be able to type code .
in any folder to start editing files in that folder. You can also open specific files with code [filenname]
Now we will use oh-my-zsh to add a useful color theme to our prompt. Use the command code ~/.zshrc
to open your zsh config file in vscode. It lives in your root folder ~/
and is hidden, hence the .
before the file name.
Add the following line in the theme section (near the top) to set the oh-my-zsh theme to a handy one called 'af-magic'. af-magic will conveniently display your git information and working directory in your shell which is very helpful. It also display virtualenv information which will be helpful when we get into python in unit 4.
ZSH_THEME="af-magic"
You can of course experiment with different themes or even make your own! There are instructions in the .zshrc file to have a different theme shown in your console every-time your start it up to explore the different flavors.
Save your .zshrc file and restart the terminal to enjoy!
Setting up SSH Key (if prompted)
You only need to do this if you had issues setting up a github token.
You might find your self having to re-authenticate GIT every time you work on your command line. Setup SSH Keys to let Github remember your machine in the future.