Skip to content
rodrigopintoPublic
forked from thoughtbot/laptop

About

A shell script to set up a macOS laptop for web and mobile development.

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Latest commit

 

History

407 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laptop

Laptop is a script to set up a macOS laptop for web and mobile development.

It can be run multiple times on the same machine safely. It installs, upgrades, or skips packages based on what is already installed on the machine.

This is a personal fork of thoughtbot/laptop, adapted for my own setup.

Requirements

We support:

  • macOS Sequoia (15.x) on Apple Silicon and Intel
  • macOS Sonoma (14.x) on Apple Silicon and Intel
  • macOS Ventura (13.x) on Apple Silicon and Intel

Older versions may work but aren't regularly tested.

Install

New machine, single command

bootstrap chains everything a brand-new Mac needs into one script: Homebrew (which pulls in Xcode Command Line Tools and git), gh plus the one GitHub login (works for a private dotfiles repo — no SSH key to generate, since gh repo clone authenticates with that login directly), cloning your dotfiles repo, symlinking its configs, and running this repo's mac script.

Wiring plain git to authenticate over HTTPS with the same login (gh auth setup-git) is left to your dotfiles repo's own setup.sh, which can scope it to just your repos.

curl -fsSL -o bootstrap https://raw.githubusercontent.com/rodrigopinto/laptop/main/bootstrap
less bootstrap   # review it — avoid running scripts you haven't read
DOTFILES_REPO=yourname/your-dotfiles-repo sh bootstrap 2>&1 | tee ~/bootstrap.log

Omit DOTFILES_REPO and it'll prompt for it — the script never hardcodes a dotfiles repo name since it's public and yours may not be.

It's safe to re-run. It will pause for: the Xcode Command Line Tools install dialog, the GitHub browser login, and whatever prompts your own dotfiles repo's setup.sh asks.

Keep the | tee ~/bootstrap.log — that's what produces the log to read if something fails. bootstrap doesn't write one itself.

Just this script

If you already have your dotfiles set up (or don't use a separate dotfiles repo), you can run mac on its own. Download the script:

curl --remote-name https://raw.githubusercontent.com/rodrigopinto/laptop/main/mac

Review the script (avoid running scripts you haven't read!):

less mac

Execute the downloaded script:

sh mac 2>&1 | tee ~/laptop.log

The script can run without dotfiles. If ~/Brewfile exists, Homebrew Bundle installs the formulae and GUI applications listed there. This file is normally provided by a separate personal dotfiles repo (symlinked into place by that repo's own setup script). If it does not exist, the script installs the base tooling and skips the Brewfile applications; run the script again after installing your dotfiles.

Homebrew Bundle is safe to rerun: it installs missing items and leaves already-installed items in place.

Optionally, review the log:

less ~/laptop.log

Debugging

Both documented commands above pipe through tee, which is what saves the run — to ~/laptop.log for mac, or ~/bootstrap.log for bootstrap. Read through it to see if you can debug the issue yourself. If not, copy the lines where the script failed into a new GitHub Issue for us. Or, attach the whole log file as an attachment.

What it sets up

macOS tools:

  • Homebrew for managing operating system libraries.
  • GUI applications listed in ~/Brewfile (normally maintained by a separate personal dotfiles repo), including Alfred, Docker Desktop, Google Chrome, Ghostty, Rectangle, Slack, Spotify, Telegram, Visual Studio Code, and Zoom.

Unix tools:

  • Universal Ctags for indexing files for vim tab completion
  • Git for version control
  • OpenSSL for Transport Layer Security (TLS)
  • RCM for managing company and personal dotfiles
  • The Silver Searcher for finding things in files
  • Tmux for saving project state and switching between projects
  • Zsh as your shell

Image tools:

Programming languages, package managers, and configuration:

  • mise for managing programming language versions
  • Bundler for managing Ruby libraries
  • Node.js and npm, for running apps and installing JavaScript packages
  • Ruby stable for writing general-purpose code
  • pi coding agent for local development assistance
  • Herdr plugins (Simple Tab Name), when Herdr is installed from ~/Brewfile
  • Rosetta 2 for running tools that are not supported in Apple silicon processors

It should take less than 15 minutes to install (depends on your machine).

Customize in ~/.laptop.local

Your ~/.laptop.local is run at the end of the Laptop script. Put your customizations there. For example:

#!/bin/sh

brew bundle --file=- <<EOF
brew "Caskroom/cask/dockertoolbox"
brew "go"
brew "ngrok"
brew "watch"
EOF

default_docker_machine() {
  docker-machine ls | grep -Fq "default"
}

if ! default_docker_machine; then
  docker-machine create --driver virtualbox default
fi

default_docker_machine_running() {
  default_docker_machine | grep -Fq "Running"
}

if ! default_docker_machine_running; then
  docker-machine start default
fi

fancy_echo "Cleaning up old Homebrew formulae ..."
brew cleanup

if [ -r "$HOME/.rcrc" ]; then
  fancy_echo "Updating dotfiles ..."
  rcup
fi

Write your customizations such that they can be run safely more than once. See the mac script for examples.

Laptop functions such as fancy_echo can be used in your ~/.laptop.local.

Contributing

Thank you, contributors!

Edit the mac file. Document in the README.md file. Update the CHANGELOG. Follow shell style guidelines by using ShellCheck.

brew install shellcheck

Testing your changes

Test your changes by running the script on a fresh install of macOS. You can use the free and open source emulator UTM.

Tip: Make a fresh virtual machine with the installation of macOS completed and your user created and first launch complete. Then duplicate that machine to test the script each time on a fresh install that's ready to go.

License

Laptop is © 2011-2023 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

This fork is maintained by Rodrigo Pinto. Originally created by thoughtbot.

About

A shell script to set up a macOS laptop for web and mobile development.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages