/dotfiles

My configuration

Primary LanguageShell

Setup instructions

This README is inspired from lewagon/setup

  • Grab a text editor, where you'll spend your day and nights
  • Install a package manager
  • Pimp your Terminal
  • Setup git and GitHub

Command Line Tools

Open the Terminal (click the magnifying glass icon in the top right corner of your screen and type Terminal):

Copy-paste the following command in the terminal and hit Enter.

xcode-select --install

If you'll receive the following message, you can just skip this step and go to next step.

# command line tools are already installed, use "Software Update" to install updates

Otherwise, it will open a window asking you if you want to install some software. Accept and wait. If it fails, try again the command line above, sometimes the Apple servers are overloaded.

While it's downloading, you can go on with configuring your GitHub account, but stop before Homebrew. You'll need the command line tools installed for that step.

GitHub account

Have you signed up to GitHub? If not, do it right away.

👉 Upload a picture and put your name correctly on your GitHub account. This is important as we'll use an internal dashboard with your avatars. Please do it now.

Homebrew

On Mac, you need to install Homebrew which is a Package Manager. It will be used as soon as we need to install some software. To do so, open your Terminal and run:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This will ask for your confirmation (hit Enter) and your laptop session password.

If you already have Homebrew, it will tell you so, that's fine, go on.

Then install some useful software:

brew update

If you get a /usr/local must be writable error, just run this:

sudo chown -R $USER:admin /usr/local
brew update

Error message or not, proceed running the following in the terminal (you can copy / paste all the lines at once).

function install_or_upgrade { brew ls | grep $1 > /dev/null; if (($? == 0)); then brew upgrade $1; else brew install $1; fi }
install_or_upgrade "git"
install_or_upgrade "wget"
install_or_upgrade "imagemagick"
install_or_upgrade "jq"
install_or_upgrade "openssl"

VSCode - Text Editor

A text editor is one of the most important tools of a developer. Go to this page and download VSCode for MacOS. Install it (double click the downloaded file and drag & drop the app into the Applications folder, don't skip this).

Hyper - Beautiful an extensible Terminal

The original terminal app from macos is fine but if you'll certainly want a better developper experience with ITerm2 or with Hyper. Donwload, and install it on this url https://hyper.is.

Oh-my-zsh - Fancy your Terminal

We will use the shell named zsh instead of bash, the default one.

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

Be careful, at the end of this script, it will prompt for your laptop password again. You have to write it correctly (you will not see it when you type) and hit Enter. You should get something like:

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!

Now quit the Terminal ( + Q), and restart it.

You should see something like this:

GitHub

We need to generate SSH keys which are going to be used by GitHub and Heroku to authenticate you. Think of it as a way to log in, but different from the well known username/password couple. If you already generated keys that you already use with other services, you can skip this step.

Open a terminal and type this, replacing the email with yours (the same one you used to create your GitHub account). It will prompt for information. Just press enter until it asks for a passphrase.

mkdir -p ~/.ssh && ssh-keygen -t ed25519 -o -a 100 -f ~/.ssh/id_ed25519 -C "TYPE_YOUR_EMAIL@HERE.com"

NB: when asked for a passphrase, put something you want (and that you'll remember), it's a password to protect your private key stored on your hard drive. You'll type, nothing will show up on the screen, that's normal. Just type the passphrase, and when you're done, press Enter.

Then you need to give your public key to GitHub. Run:

cat ~/.ssh/id_ed25519.pub

It will prompt on the screen the content of the id_ed25519.pub file. Copy that text, then go to github.com/settings/ssh. Click on Add SSH key, fill in the Title with your computer name, and paste the Key. Finish by clicking on the Add key green button.

To check that this step is completed, in the terminal run this. You will be prompted a warning, type yes then Enter.

ssh -T git@github.com

If you see something like this, you're done!

# Hi --------! You've successfully authenticated, but GitHub does not provide shell access

If it does not work, try running this before trying again the ssh -T command:

ssh-add ~/.ssh/id_ed25519

Dotfiles (Standard configuration)

Hackers love to refine and polish their shell and tools. We'll start with a great default configuration provided by Me ( Mheaus ), stored on GitHub. As your configuration is personal, you need your own repository storing it, so you first need to fork it to your GitHub account.

➡️ Click here to fork the mheaus/dotfiles repository to your account. Forking means that it will create a new repo in your GitHub account, identical to the original one. You'll have a new repository on your GitHub account, your_github_username/dotfiles. We need to fork because each of you will need to put specific information (e.g. your name) in those files.

Open your terminal. Don't blindly copy paste this line, replace replace_this_with_your_github_username with your own github usernickname.

export GITHUB_USERNAME=replace_this_with_your_github_username

# Example:
#   export GITHUB_USERNAME=mheaus

Now copy/paste this very long line in your terminal. Do not change this one.

mkdir -p ~/code/$GITHUB_USERNAME && cd $_ && git clone git@github.com:$GITHUB_USERNAME/dotfiles.git

Run the dotfiles installer.

cd ~/code/$GITHUB_USERNAME/dotfiles
zsh install.sh

Then run the git installer:

cd ~/code/$GITHUB_USERNAME/dotfiles
zsh git_setup.sh

☝️ This will prompt you for your name (Firstname Lastname) and your email.

Be careful, you need to put the same email as the one you sign up with on GitHub.

Please now quit all your opened terminal windows.

SSH Passphrase

In a terminal window, launch this command:

sw_vers

If your OS version (ProductVersion line) is greater or equal than 10.12, you may proceed with the rest of this section. ⚠️ Otherwise, skip it and go directly to the Ruby install.

In order not to re-type your SSH passphrase at every git push, you can add these lines to the ~/.ssh/config file:

touch ~/.ssh/config  # Creates the file if it does not exist
st ~/.ssh/config     # Opens the file in Sublime text

And then add these 3 lines to the file. Save.

Host *
  AddKeysToAgent yes
  UseKeychain yes

Security

It is mandatory that you protect your session behind a password.If it is not already the case, go to  > System Preferences > Users & Groups, and change your account password. You should also go to  > System Preferences > Security > General. You should require a password 5 seconds after sleep or screen saver begins.

You can also go to  > System Preferences > Mission Control, and click on the Hot Corners button at the bottom left. Choose for the bottom right corner to start the screen saver. That way, when you leave your desk, you can quickly lock you screen by putting your mouse in the bottom right corner. 5 seconds after, your Macbook will be locked and will ask for a password to get back on the session.

Check-up

Let's check if you successfully installed everything.

Quit all opened Terminal, open a new one and run the following commands:

curl -Ls https://raw.githubusercontent.com/lewagon/setup/master/check.rb > _.rb && ruby _.rb || rm _.rb

It should tell you if your workstation is ready :) If not, ask a teacher.

Keyboard

As you become a programmer, you'll understand that leaving the keyboard takes a lot of time, so you'll want to minimize using the trackpad or the mouse. Here are a few tricks on OSX to help you do that:

Keyboard speed

Go to  > System Preferences > Keyboard. Set Key Repeat to the fastest position (to the right) and Delay Until Repeat to the shortest position (to the right).

Full Keyboard Access

Go to  > System Preferences > Keyboard. Click on the third tab (Shortcuts). At the bottom of the pane, click the radio button All controls. This way when you get a dialog with several options, you'll be able to type Enter to confirm, or Space to choose the cancel option. If you have more than two options, you can use tab to circle between them.

macOS For hackers

Read this script and cherry-pick some stuff you think will suit you. For instance, you can type in the terminal this one:

# Expanding the save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true

# Save screenshots to the Desktop (or elsewhere)
defaults write com.apple.screencapture location "${HOME}/Desktop"

# etc..