2 Setting up your computer

2.1 First-time Git setup

The first thing you should do before to use Git is set your identity, open the terminal and execute the following commands:

> git config --global user.name "Your name here"
> git config --global user.email "your_email@hypermynds.com"

GitHub no longer accept the password authentication since August 2021, now a SSH key must be used to access to your repositories.

  • Open the terminal and execute the following command to create a new SSH key:

    > ssh-keygen -t ed25519 -C "your_email@hypermynds.com" -f ~/.ssh/github -N ""
  • Open your SSH configuration file with the command open ~/.ssh/config (if it doesn’t exist create it with the command touch ~/.ssh/config) and add the following lines:

    Host github.com
        AddKeysToAgent yes
        IdentitiesOnly yes
        IdentityFile ~/.ssh/github
  • Copy your public key with the command pbcopy < ~/.ssh/github.pub and paste the key in the section SSH and GPG keys of your GitHub settings (click on New SSH key button).

2.2 Security and privacy configuration

To mantain an high standard of security for personal laptop all the employees must follow these guidelines:

  • Computers must use hard drive encryption:

    1. choose Apple menu () then System Preferences and click Security & Privacy;
    2. click the FileVault tab;
    3. click Turn On FileVault;
    4. choose to create a local recovery key and communicate the recovery key to your manager (do not use instant messaging or mail message).
  • Firewall must be enabled:

    1. choose Apple menu () then System Preferences and click Security & Privacy;
    2. click the Firewall tab;
    3. click Turn On Firewall button.
  • Disable automatic login and require the password when waking from sleep (if FileVault is activated then automatic login is already disabled):

    1. choose Apple menu () then System Preferences and click Security & Privacy;
    2. click the General tab;
    3. select the option to require password immediately after sleep or screen saver begin.

2.3 How to install the software using Homebrew

Homebrew is the easiest way to install the software and keep it updated. To install Homebrew execute the following command in the Terminal and follow the instructions:

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

Once that Homebrew has been installed close the Terminal and open it again, you can check if everything is ok executing the command brew --version, you will see something like this:

> brew --version
Homebrew 3.3.9
Homebrew/homebrew-core (git revision 8600fa3966f; last commit 2021-12-21)
Homebrew/homebrew-cask (git revision 17172f9d63; last commit 2021-12-21)

To complete the Homebrew setup you should install also brew-cask-update executing the command:

brew tap buo/cask-upgrade

2.3.1 Keep everything updated

Homebrew handles the updates of installed softwares by itself, you don’t need to download or reinstall the software checking if a new version of some package has been released. To keep everything updated you should follow the steps:

  1. command brew update download the updated list of the packages provided by Homebrew;
  2. command brew outdated gives you the list of outdated packages, so you can check if something will break your work;
  3. command brew upgrade updates all the outdated packages installing the new available versions;
  4. command brew cu updates all the cask packages (usually ignored by the upgrade command).

2.3.2 Essential commands

brew doctor

Check your system for potential problems.

brew info <package>

Show summary of information about a package.

brew install [--cask] <package>

Install a package or cask.

brew list

List all installed packages and casks.

brew outdated

List installed casks and packages that have an updated version available.

brew reinstall [--cask] <package>

Uninstall and then reinstall a package or cask.

brew search <text>

Perform a substring search of cask and package names.

brew uninstall <package>

Uninstall a package or cask.

brew update

Fetch the newest version of Homebrew and all packages.

brew upgrade [<package>]

Upgrade outdated casks and outdated packages. If cask or package are specified, upgrade only the given cask or package.

2.4 Setting up the R development environment

R and RStudio can be installed using Homebrew:

> brew install --cask r
...
> brew install --cask rstudio
...

RStudio is installed in your /Applications directory, to check if everything has been setup correctly it is enough to open it.

2.4.1 Set your Github Personal Access Token

To interact with private repositories or avoid the GitHub rate limits for unauthenticated users you have to create a GitHub Personal Access Token:

Open R or RStudio and execute the following commands:

install.packages('usethis')
usethis::create_github_token()

R will open your browser and redirect it to the page for creating the token (probably it prompt for your password), set the name of the token to “R” and the expiration time to 90 days (tokens without expiration are unsecure), leave everything else untouched and click the button “Create token” at the and of the page.

GitHub will show you the new created token (the ugly string with green background), copy it and close the page.

Execute the following R command:

usethis::edit_r_environ()

Now the file ~/.Renviron will be opened with your preferred editor, now you can add (or update) the line:

GITHUB_PAT=<PUT HERE THE GITHUB TOKEN AND NOT THESE MEANINGLESS WORDS>

For security reasons it is a good idea to change the permissions of ~/.Renviron executing the following command in the Terminal:

chmod 0600 ~/.Renviron

2.5 Slack

Slack is the communication platform we use @Hypermynds to chat, interact, manage projects and share thoughts about work and life.

To install Slack on your laptop you can use Homebrew:

> brew install --cask slack

Then you can access using your work email that you should have received from your manager.