#!/usr/bin/env zsh # Script to start monorepo development processes in separate terminals open_position_run() { local dir=$1 local cmd=$2 # Start the server osascript -e 'tell application "Terminal" do script "cd '"$dir"' && nvm use 20 && '"$cmd"' &" in window 1 end tell' } open_position_run "/Users/bakert/monorepo/apps/app1 "pnpm dev" open_position_run "/Users/bakert/monorepo/apps/app2 "pnpm dev"
History (Fourth Time)
I did this in 2008, 2011 and 2015 but forgot to do it for ten years.
[zarniwoop ~] history 0 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head 34675 git 5294 composer 4376 cd 3761 vi 3076 pnpm 2914 python 2188 m 1917 ls 1822 python3 1717 ssh
Compared to 2015. New: composer, pnpm, python/python3, m (run scripts for an app I work on). Climbers: git, cd. Fallers: ssh, ls. Old: c, php, pass, sudo, ruby.
COUNT(*) OVER () in Drizzle
In general I like to use COUNT(*) OVER ()
to get the total count for a query when retrieving a slice with OFFSET and LIMIT (very useful for pagination) rather than issuing a separate query for the total count. This is not super well supported in Drizzle but you can do it like this:
const data = await db.query.tableName.findMany({ … extras: { // Weird cast here because COUNT(*) is a bigint which is handled as a string in js // https://orm.drizzle.team/docs/guides/count-rows total: sql<number>`CAST(COUNT(*) OVER() AS INTEGER)`.as("total"), }, …
Set Up a New Mac (May 2025 Edition)
Previously: July 2019, July 2022, August 2023
- Upgrade to latest MacOS
- Restore from Blackblaze backup: u directory, dotfiles, .atuin dir, .config dir, .cursor dir, .nvm-zsh dir, .ssh dir, .vim dir, any other dot dirs that look useful, ~/Library/Application Support/Alfred
- Set perms on .ssh
$ cd ~ && chmod 600 ~/.ssh/* && chmod 700 ~/.ssh && chmod 644 ~/.ssh/*.pub
- Set perms on ~/u/bin
$ chmod u+x ~/u/bin/*
- Hide Desktop icons
$ defaults write com.apple.finder CreateDesktop false $ killall Finder
- Show hidden files in Finder with Cmd-Shift-.
- 1Password
- Dock: remove everything, hiding on, magnification on
- Alfred (and give it Accessibility access, add license key)
- System Settings, Mouse, set Trackpad speed to max and enable right-click
- Sublime Text 4 (add license key, set
"trim_trailing_white_space_on_save": "all"
in sublime prefs, install Package Control, install Nord Theme via Package Control) - subl commandline sublime.
$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/u/bin/subl
- sublime git-ignorer. (1) add Package Control repo https://github.com/apc999/sublime-text-gitignore (2)
install package sublime-text-gitignore (3) use menu item : File->Exclude Git-ignored (4) Give this a keyboard shortcut in Sublime, Preferences, Key Bindings with{ "keys": ["super+shift+i"], "command": "exclude_ignored" }
- Keyboard shortcut to toggle word wrap in Sublime Text. Preferences, Key Bindings
{ "keys": ["super+shift+w"], "command": "toggle_setting", "args": { "setting": "word_wrap" } }
- Install FiraCode and add it to Sublime Text prefs with
"font_face": "Fira Code"
. - Nord theme for Terminal and make default in preferences.
- Polar theme for terminal when ssh’ing to remotes
- For both Nord and Polar themes: “Use Option as Meta Key” in Terminal to make left Alt work as Esc. And Terminal, Settings, Advanced, un-check “Audible bell” and “Only when sound is muted”. And Shell, (When the shell exits) “Close the window”.
- System Preferences, Sound, turn “Alert volume” all the way down
- Use Ctrl-f7 to enable keyboard navigation of dialogs
- Homebrew. (Installs OSX commandline tools)
- Discord
- Change all .txt to open with Sublime Text
- Chrome. Sign in to Chrome to get extensions, then tell it you really do want uBlock Origin via “Keep for Now” under Extensions in Settings. Uninstall Chrome if they’ve finally locked it down entirely
- Firefox. Sign in to sync extensions. Set as default browser. Settings, search for “Autoplay”, Settings, Allow Audio and Video. Visit each extension you want in Private Browsing and select Run in Prviate Windows
- Skitch
- Backblaze. Choose to inherit the previous backup (it won’t copy anything down). Give System Settings, Privacy & Security, Full Disk Access
- Parallels Desktop + Windows + MTGO
- Disable Ask Siri in System Preferences, Siri
- Turn on “tap to click” in System Preferences, Trackpad
- Disable long-press (it’s annoying when selecting text in Chrome):
defaults write -g ApplePressAndHoldEnabled -bool false
- Spotify
- Slack
- Rectangle Pro
- DaisyDisk
- ChatGPT
- Claude
- Linear
- Zed
- Notion
brew install nvim
brew install mariadb
brew install npm
brew install pnpm@9
brew install apache2
.brew install php
. Enable in Apache with LoadModule, FilesMatch and DirectoryIndex directives as per homebrew output andbrew services restart apache2
.brew install gh
brew install composer
brew install bat
brew install atuin && atuin import auto
brew install delta
brew install vercel-cli
npm install -g rtm-cli
git clone
important repos (ff, pd, monorepo)- Restore any local databases for dev (ff, decksite, logsite)
ln -s ~/ff/src/www /opt/homebrew/var/www/ff
GRANT ALL ON ff.* TO ff@localhost IDENTIFIED BY *REDACTED*
- pd setup
- Check open but unsaved files in Sublime Text in case there’s anything you need to preserve
git status
in any recent repos and check for uncommitted work.
zsh “shortcuts”
$ cat ~/.config/zsh/nav.zsh ───────┬───────────────────────────────────────────────────────────────────── │ File: /Users/bakert/.config/zsh/nav.zsh ───────┼───────────────────────────────────────────────────────────────────── 1 │ export MONOREPO_ROOT="/Users/bakert/cardeio-monorepo-v2" 2 │ export ORGANIZED_PLAY="$MONOREPO_ROOT/apps/organized-play" 3 │ export PLAY_NEXT="$MONOREPO_ROOT/apps/play-next" 4 │ export LUDWIG="$MONOREPO_ROOT/apps/ludwig" 5 │ export CARD_SEARCH_DEMO="$MONOREPO_ROOT/apps/card-search-demo" 6 │ export DECK_BUILDER="$MONOREPO_ROOT/packages/deck-builder" 7 │ 8 │ hash -d mr="$MONOREPO_ROOT" 9 │ hash -d op="$ORGANIZED_PLAY" 10 │ hash -d pn="$PLAY_NEXT" 11 │ hash -d lw="$LUDWIG" 12 │ hash -d cs="$CARD_SEARCH_DEMO" 13 │ hash -d db="$DECK_BUILDER" ───────┴──────────────────────────────────────────────────────────────────────
Use prefixed with ~ anywhere you need a path:
$ cd ~mr $ vi ~lw/src/index.ts
Git – You’re Doing It Wrong
Instead of | Do this |
git checkout {file} | git restore {file} |
git checkout {branch} | git switch {branch} |
git checkout -b {newbranch} | git switch -c {newbranch} |
git push --force | git push --force-with-lease |
How to make Firefox auto-suggest “shortcut URLs”
I just switched back to Firefox (ublock origin forever!) and it massively down-rates URLs that redirect in its “what to auto-suggest” algorithm. You can tweak this, though, by putting `about: config` into the URL bar and setting `places.frecency.permRedirectVisitBonus` and `places.frecency.redirectSourceVisitBonus` to 2000 over their initial low values.
firefox-source-docs.mozilla.org/browser/urlbar/ranking.html has all the gory details and more.
pipenv no longer chokes on `python_requires=”==3.*”`
As of version 2024.04 this bug that I investigated earlier in the year has been fixed. Hurray!
Nord Light Theme
I like my terminal to change theme when I ssh into another machine. I have been using Solarized Light and Solarized Dark to facilitate this for some time. But now I have gotten hooked on Nord which has no light version. So I made one, just for Terminal for now at least.
There are notes about a “bright ambiance” version of the theme in the Nord docs but no actual themes available. The official Terminal.app theme actually deviates from the core 16-color palette but I didn’t do that here. I just chose the most appropriate color from the 16 color palette for each option in a Terminal theme.
Avoid trailing comma when emitting lists in Mustache templates
In pure Mustache there’s no (simple) way to avoid a trailing comma on a list:
{{#items}}{{.}}, {{/items}}
Which produces something like: “First, Second, Third, “
There are various ways around this. If you’re working in HTML I think the nicest is to model your list as an actual HTML list and use CSS:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>Lists</title> <style> .list { margin: 0; padding: 0; } .list li { display: inline; } .list li:not(:last-child):after { content: ", "; } </style> </head> <body> <ol class="list"> <li>First</li> <li>Second</li> <li>Third</li> </ol> </body> </html>
Which produces: “First, Second, Third”.