Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,14 @@ sudo softwareupdate --install-rosetta
# chezmoi
```bash
brew install chezmoi
brew install lastpass-cli
lpass login peter@sparetimecoders.com
```

```bash
chezmoi init --apply peter-svensson
```

## Adding stuff to Lastpass
## Secrets Management (Proton Pass)

```bash
echo "$(cat ~/.gnupg/pubring.kbx | base64)" | lpass add --sync=now --non-interactive --notes "lambda/gnupg-pubring.kbx"
```
Secrets are managed via Proton Pass using chezmoi's built-in `protonPass` and `protonPassJSON` template functions.

### SSH keys
```bash
printf "Private Key: %s\nPublic Key: %s" "$(cat ~/.ssh/id_rsa_plint_git)" "$(cat ~/.ssh/id_rsa_plint_git.pub)" | lpass add --sync=now --non-interactive --note-type=ssh-key "plint/git ssh key"
```
Ensure the Proton Pass CLI is installed and authenticated before running `chezmoi apply`.
4 changes: 4 additions & 0 deletions dot_bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ fi
if command -v direnv &> /dev/null; then
eval "$(direnv hook bash)"
fi

if command -v wt >/dev/null 2>&1; then eval "$(command wt config shell init bash)"; fi

. "$HOME/.local/share/../bin/env"
6 changes: 6 additions & 0 deletions dot_config/fish/config.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# conf.d runs first!

# Force CLI tools to use English regardless of macOS language settings
set -gx LANGUAGE en_US.UTF-8

# https://fishshell.com/docs/current/tutorial.html
# https://github.com/jorgebucaran/fish-shell-cookbook
# https://github.com/fish-shell/fish-shell/blob/master/share/config.fish
Expand Down Expand Up @@ -63,3 +66,6 @@ end
# This won't be added again if you remove it.
source ~/.orbstack/shell/init2.fish 2>/dev/null || :

# Scaleway CLI autocomplete initialization.
eval (scw autocomplete script shell=fish)

42 changes: 29 additions & 13 deletions dot_config/fish/functions/brew/bup.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ function bup -d "Update homebrew, upgrade installed packages, and cleanup"
if test $status -ne 0
if test (echo "$result" | grep -c 'uninstall') -gt 0
echo "Missing installed dependencies in Brewfile $file"
echo "Update before running again"
string join \n $result
echo "Update before running again, e.g.:"
echo " brew bundle cleanup --file $file --force"
string join \n $result \
| string replace -a 'brew bundle cleanup --force' "brew bundle cleanup --file $file --force"
return
else
echo "Errors in Brewfile $file?"
Expand All @@ -17,8 +19,17 @@ function bup -d "Update homebrew, upgrade installed packages, and cleanup"
end

echo "Brewfile matches installation, updating packages"
brew update && brew upgrade && brew cleanup
brew update && brew upgrade; brew cleanup

# Clean up stale caskroom directories left by failed upgrades (e.g. rename errors)
set -l caskroom (brew --caskroom)
for stale_dir in (command ls -1 "$caskroom/" 2>/dev/null)
for suffix_dir in (command ls -1 "$caskroom/$stale_dir/" 2>/dev/null | string match '*.upgrading')
echo "Cleaning up stale upgrade directory: $stale_dir/$suffix_dir"
command rm -rf "$caskroom/$stale_dir/$suffix_dir"
end
end

for cask in (brew list --cask)
brew info --cask $cask --json=v2 \
| jq -r '.casks[0] | [(.outdated | tostring), (.installed // "NONE"), .version] | @tsv' \
Expand All @@ -29,28 +40,33 @@ function bup -d "Update homebrew, upgrade installed packages, and cleanup"
echo "Upgrading $cask from $installed to $current"
set -l manual_installer (brew info --cask $cask --json=v2 \
| jq -r '.casks[0].artifacts[] | select(.installer) | .installer[] | select(.manual) | .manual // empty')
# Clean up old version directories that block upgrades
for old_ver in (command ls -1 "$caskroom/$cask/" 2>/dev/null)
if test "$old_ver" != "$current"
echo "Removing old caskroom version: $cask/$old_ver"
command rm -rf "$caskroom/$cask/$old_ver"
end
end
if test -n "$manual_installer"
# Manual installers need reinstall + open the installer
for old_ver in (command ls -1 "$caskroom/$cask/" 2>/dev/null)
if test "$old_ver" != "$current"
command rm -rf "$caskroom/$cask/$old_ver"
end
end
if brew reinstall --cask --force $cask
set -l installer_path "$caskroom/$cask/$current/$manual_installer"
if test -e "$installer_path"
echo "Opening manual installer: $installer_path"
open "$installer_path"
if not open "$installer_path"
echo "Warning: 'open' failed for $installer_path"
echo "Run manually: open \"$installer_path\""
end
else
echo "Warning: installer not found at $installer_path"
echo "Check $caskroom/$cask/ manually"
end
else
echo "Warning: failed to reinstall $cask, skipping"
end
else
brew upgrade --cask --greedy $cask; or echo "Warning: failed to upgrade $cask, skipping"
else if not brew upgrade --cask --greedy $cask
# Upgrade failed, likely stale caskroom dir -- clean up and force reinstall
echo "Retrying $cask: cleaning caskroom and reinstalling"
command rm -rf "$caskroom/$cask"
brew install --cask --force $cask; or echo "Warning: failed to reinstall $cask, skipping"
end
else
echo "$cask:$current is latest version"
Expand Down
3 changes: 2 additions & 1 deletion dot_local/share/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ brew "kubernetes-cli"
brew "kops"
brew "kube-ps1"
brew "kustomize"
brew "lastpass-cli"
brew "ldns"
brew "libidn"
brew "libpq"
Expand Down Expand Up @@ -102,6 +101,7 @@ brew "python@3.11"
brew "rbenv"
brew "ripgrep"
brew "rsync"
brew "scw"
brew "ruby"
brew "screen"
brew "shfmt"
Expand Down Expand Up @@ -166,6 +166,7 @@ go "tools/cmd/aws-iam-users"
go "tools/cmd/aws-users"
go "golang.org/x/tools/cmd/deadcode"
go "github.com/gesquive/fast-cli"
go "github.com/richardartoul/gobuildcache"
go "github.com/google/go-licenses"
go "github.com/lietu/go-pre-commit"
go "github.com/kevincobain2000/gobrew/cmd/gobrew"
Expand Down