Set up a macOS machine as a software development environment.
Ed25519 uses elliptic curve cryptography with good security and performance.
Create the key:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "$(whoami)@$(hostname)"Start the SSH agent:
eval "$(ssh-agent -s)"Add the private key to the SSH agent on macOS:
ssh-add --apple-use-keychain ~/.ssh/id_ed25519Copy the public key to macOS clipboard:
cat ~/.ssh/id_ed25519.pub | pbcopyUpload the public key to GitHub.
Set your Git and GitHub user in ~/.gitconfig.local
to keep it out of version control:
[github]
user = yourgithubusername
[user]
name = Your Name
email = you@example.com
createtree uses soc checkout when origin matches a configured
sockeye server, and git create-tree for other repos. mergetree and
closetree use the same server selection.
co <change-id> changes directory to an existing change's worktree,
from any directory. soc picks the server from the change id. When the
checkout fails, co keeps the current directory.
soc is the binary that go install ./cmd/soc installs from a clone of
sockeye, not a shell function. soc checkout and soc co print the
worktree path, so cd $(soc co <change-id>) changes directory.
Keep instance URLs in ~/.gitconfig.local:
[sockeye]
url = https://personal.example.com
[sockeye "dc"]
url = https://personal.example.com
[sockeye "ivp"]
url = https://work.example.com~/.gitconfig is a symlink to git/gitconfig, which this repo
tracks. So soc login, soc git setup, and git config --global
write into the tracked file. Move what they write to
~/.gitconfig.local. git/gitconfig includes that file.
After you log in, move the credential block for the server:
[credential "https://personal.example.com"]
helper =
helper = !soc auth git-credentialThe token is in ~/.config/sockeye/token. The Keychain has no copy.
The credential block sends git to soc auth git-credential for the
token. The empty helper clears the osxkeychain helper in
git/gitconfig. GitHub uses gh the same way. Other hosts use the
Apple-signed osxkeychain helper.
soc checkout cuts a worktree from a local clone of the change's
repo. It finds a clone at ~/<slug> or behind a worktree in
~/.worktrees. For a clone in a different place, set the
sockeye.clone.<slug> key in ~/.gitconfig.local, not with the
--global that the error from soc gives. Use an absolute path,
because soc does not expand ~:
git config --file ~/.gitconfig.local sockeye.clone.abc "$HOME/some-dir"soc-dc and soc-ivp select an instance for one command, such as
soc-ivp login or soc-dc show SOC-1. They do not change the saved
default. An explicit checkout still needs a clone from that instance.
Tree helpers select origin's server even when SOCKEYE_URL names
another server. Register each server before using its tree helpers.
Run the isolated helper tests with zsh -f shell/zshrc_test.zsh.
The tests use local stub commands and do not contact a server.
Clone onto laptop:
export LAPTOP="$HOME/laptop"
git clone https://github.com/croaky/laptop.git $LAPTOP
cd $LAPTOP
Review:
less laptop.sh
Run:
./laptop.sh
The script can safely be run multiple times. It is tested on the latest version of macOS on an arm64 (Apple Silicon) chip.
The script links the dotfiles to the main clone, ~/laptop,
also when it runs from a change worktree.
So a test run from a worktree is safe after mergetree deletes it.
A change to a dotfile, such as shell/zshrc,
takes effect after the merge and a git pull in ~/laptop.
laptop.sh turns off all four hot corners.
A hot corner set to Mission Control opens
when a drag crosses a display corner,
and a dragged screenshot then cannot reach its window.
The F3 key still opens Mission Control.
To use a hot corner, set it in
"System Settings > Desktop & Dock > Hot Corners".
The next run of laptop.sh turns it off again.
laptop.sh turns off "Click wallpaper to reveal desktop".
When this setting is on, a click on the wallpaper
moves all windows to the screen edges.
A screenshot drag that starts or crosses the wallpaper can do this,
and the target window then moves away.
To turn it on, set it in
"System Settings > Desktop & Dock".
The next run of laptop.sh turns it off again.
laptop.sh sets three shortcuts for the
"Window > Move & Resize" menu in every app:
- Control-Option-Left: "Left" (left half)
- Control-Option-Right: "Right" (right half)
- Control-Option-Return: "Fill" (full screen area)
An app reads the shortcuts when it starts. Quit and reopen an app that runs, or log out and in. "Fill" does not go back to the old size. Use "Window > Move & Resize > Return to Previous Size" for that. To see or change the shortcuts, go to "System Settings > Keyboard > Keyboard Shortcuts > App Shortcuts".
Separate from the script, the following README sections are "one time setup" items.
Install macOS apps:
Configure "System Settings > Keyboard":
- Set "Key Repeat" to "Fast".
- Set "Delay Until Repeat" to "Short".
- Set "Modifier Keys > Caps Lock Key" to "^ Control".
Disable "Press and Hold" accent menu to allow key repeat for all keys:
defaults write -g ApplePressAndHoldEnabled -bool falseSet DNS resolver to 1.1.1.1,
a fast, privacy-focused DNS service from Cloudflare:
- Go to "System Settings > Network > Advanced... > DNS"
- Click "+"
- Enter "1.1.1.1"
- Click "OK"
- Click "Apply"
A macOS feature that scans new binaries for malware adds an extra ~2s on to every build of Go programs, disturbing its fast iteration cycle. Disable it by running:
sudo spctl developer-mode enable-terminal
Then:
- Go to "System Settings > Privacy & Security > Developer Tools"
- Select "Warp" as the terminal program.