Laptop is a script to set up your computer for software development.
It's idempotent and installs, upgrades, or skips packages based on what is already installed on the machine. In otherwords, there's no downside to running it again and again.
It supports macOS on Apple Silicon and Intel processors.
Inspired by Thoughtbot's Laptop, and I hope this inspires you too!
A few secrets are required to get setup. Laptop is configured to retreive these secrets from 1Password. So you're going to need 1Password for this to work out of the box.
-
Download, install, and login to the 1Password MacOS application.
-
Create a GitHub Personal Access Token.
-
Unlock 1Password and add a
Login
item calledGitHub
with at least the followingfields
:Type Label Example Value Description text name
John Smith Full name to be used in Git configuration text email
[email protected] Personal email address to be used in Git configuration password token
github_pat_asdfjkl GitHub Personal Access Token to be used with GitHub CLI text username
jsmith GitHub username -
Generate and save a new SSH Key in 1Password with the name
GitHub SSH Key
. -
Create a Authentication SSH Key in GitHub with the public portion of the SSH Key you just added to 1Password.
-
Create a Signing SSH Key in GitHub with the public portion of the SSH Key you just added to 1Password.
-
Enable 1Password App Integration so you can use the 1Password CLI. Check at least the following:
- ✅ Use the SSH Agent
- ✅ Integrate with 1Password CLI
-
Review the mac script. Avoid running a script you haven't read!
-
Run the mac script.
curl -o- https://raw.githubusercontent.com/ssmereka/laptop/main/src/mac | zsh
This will clone the git project to ~/code/laptop
and setup your computer!
Laptop installs software and configures your Laptop. It also provides some useful commands. Run the command help
in your terminal for a list of available commands. (You may need to relaunch your terminal if the command doesn't work)
Want the latest updates? Just re-run the mac script again:
curl -o- https://raw.githubusercontent.com/ssmereka/laptop/main/src/mac | zsh
Optionally, use the Laptop alias:
lt-update
Laptop installs and configures the following software:
- 1Password CLI for secret management from the commandline.
- asdf for managing programming language versions.
- Go via the asdf-golang plugin.
- Node.js and npm via the asdf-nodejs plugin.
- Python via the asdf-python plugin.
- Ruby via the asdf-ruby plugin.
- Atuin
- Core Utils for GNU File, Shell, and Text utilities.
- Curl for interacting with URLs from the commandline.
- Gawk for interacting with files via the commandline.
- Git configures the local mac Git client for use with 1Password and GitHub.
- GitHub CLI for interacting with the GitHub API.
- GnuPG for encryption and signing.
- Homebrew for managing operating system libraries.
- Visual Studio Code for a programming IDE.
- Zshconfigures zsh with some opinions (see the Zsh Manual).
Laptop will configure your computer in a very opinionated way. Let's describe those opinions and how the script is configured to meet them.
Terminal history should persist indefinitely as evidence of the actions you have taken.
Your history is a timeline of actions you have taken that can be leveraged for a number of use-caes. Like recalling what you did to setup an application. Or reviewing actions taken during an outage.
The zsh history is configured to store all (well... 999,999,999) events in the terminal and the ~/.zsh_history
file. With each event containing a timestamp (in seconds since the epoch) and duration (in seconds) of the command. The history is shared across all terminal sessions, as if they were a single session.
If you need to enter secret information into your terminal prefix the command with a space
, like " SECRET=my-password"
. Any command the begins with a space
will not be stored in the history.
Use Atuin (using the Up Arrow
or CTRL+R
) to interactively view and search your history. Programmatically search with the history
command, like history | grep <search term here>
.
When developing you want your development environment to be as close to production as is reasonable. Switching between mutliple versions of software is complicated. To make switching easier, use version managers and package managers.
Homebrew, mac's unofficial package manager, is installed and used to manage the installation of 3rd party software, like 1password
and curl
.
Language version managers are installed for Node.js, Python, Go, and Ruby. Enabling you to quickly install and use different versions for each application you are developing. These version manager are all managed by asdf. This makes interaction with version managers more consistant as you switch between them or need to add/remove version managers.
Coding projects from git repositories are stored in the local ~/code
directory. This make it easy to find git projects.
Secrets belong in a password manager or secret storage and you should authorize when anything tries to access those secrets. Laptop will install and configure the 1Password CLI so that secrets can be retrieved programmatically. Git is also configured to use 1Password for authentication and signing.
You can customize Laptop for each computer by placing files in the ~/.laptop
directory. If provided, the following files will be used:
.custom_install.sh
- Script that will be run at the end of the Laptopinstall
.
Here's a .custom_install.sh
example:
#!/bin/zsh
brew bundle --file=- <<EOF
brew "ngrok"
EOF
Write your customizations such that they can be run safely more than once.