#!/bin/bash SCRIPT_SOURCE="${BASH_SOURCE[0]}" while [[ -L "$SCRIPT_SOURCE" ]]; do SCRIPT_DIR="$(cd -P "$(dirname "$SCRIPT_SOURCE")" >/dev/null 2>&1 && pwd)" SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")" [[ "$SCRIPT_SOURCE" != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE" done SCRIPT_DIR="$(cd -P "$(dirname "$SCRIPT_SOURCE")" >/dev/null 2>&1 && pwd)" ARCH=`uname -m` if [[ $ARCH == "arm64" ]]; then PREFIX="/opt/homebrew/" else PREFIX="/usr/local/" fi function set_permissions { echo "----------" echo "Disabling Quarantine for Casks ..." echo "----------" sudo find $PREFIX/Caskroom -name *.app -exec bash -c "xattr -d com.apple.quarantine {} 2> /dev/null" \; sudo find $PREFIX/Caskroom -type f -perm +111 -exec bash -c "xattr -d com.apple.quarantine {} 2> /dev/null" \; sudo find /Applications/ -name *.app -exec bash -c 'xattr -d com.apple.quarantine "{}" 2> /dev/null' \; sudo find /Applications/ -type f -perm +111 -exec bash -c 'xattr -d com.apple.quarantine "{}" 2> /dev/null' \; } function software_update { echo "----------" echo "Running software update" echo "----------" softwareupdate --all --install --force } function update_brew { echo "----------" echo "Updating brew software" echo "----------" brew update sudo -u $USER brew upgrade echo "----------" echo "Updating casks" echo "----------" sudo -u $USER brew upgrade --cask --greedy --verbose } function cleanup { echo "----------" echo "Running cleanup" echo "----------" sudo -u $USER brew cleanup -s } function diagnostics { echo "----------" echo "Running diagnostics" echo "----------" brew doctor brew missing } function update_others { echo "----------" echo "Update other stuff" echo "----------" if [ -x "$(command -v claude)" ]; then echo "-- CLAUDE" claude --update echo "-- CLAUDE PLUGINS" claude plugin marketplace update # No pipe into the loop: update must keep the terminal as stdin for its # confirm prompt (bun's kqueue rejects a `< /dev/tty` redirect) plugins=$(claude plugin list --json \ | python3 -c 'import json, sys; print(*(p["id"] for p in json.load(sys.stdin) if p["scope"] == "user"))') for plugin in $plugins; do claude plugin update --scope user "$plugin" done fi if [ -x "$(command -v codex)" ]; then echo "-- CODEX" codex update echo "-- CODEX PLUGINS" codex plugin marketplace upgrade fi # Skills installed via the skills CLI (shared by Claude, Codex, ...) if [ -f "$HOME/.agents/.skill-lock.json" ] && [ -x "$(command -v skills)" ]; then echo "-- SKILLS" skills update --global --yes fi if [ -x "$(command -v pi)" ]; then echo "-- PI Agent" pi update pi update --extensions fi echo "-- ALACRITTY" "$SCRIPT_DIR/install_alacritty_mac.sh" || echo "Alacritty update failed." >&2 if [ -f "$HOME/.antidote/antidote.zsh" ]; then echo "-- ANTIDOTE" zsh "$HOME/.antidote/antidote.zsh" update fi if [ -x "$HOME/.tmux/plugins/tpm/bin/update_plugins" ]; then echo "-- TMUX PLUGINS" "$HOME/.tmux/plugins/tpm/bin/clean_plugins" "$HOME/.tmux/plugins/tpm/bin/update_plugins" all fi if [ -x "$(command -v nvim)" ]; then echo "-- NVIM PLUGINS" # Headless vim-plug only logs to its buffer; print it nvim --headless -c 'PlugClean!' -c 'PlugUpgrade' -c 'PlugUpdate --sync' \ -c 'lua io.write("\n", table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n"), "\n")' \ -c 'qa' fi } if [[ $* == *--help* ]]; then echo "Usage: $0 [option]" echo "Default options: --brew-update --update-others --cleanup --diagnostics" echo -e "Options:\n\t--brew-update\n\t--update-others\n\t--cleanup\n\t--diagnostics\n\t--permission-fix\n\t--system-update" fi if [[ -z $* ]]; then set -- "$*" "--brew-update --cleanup --diagnostics --update-others" fi if [[ $* == *--system-update* ]]; then software_update fi if [[ $* == *--brew-update* ]]; then update_brew fi if [[ $* == *--update-others* ]]; then update_others fi if [[ $* == *--cleanup* ]]; then cleanup fi if [[ $* == *--diagnostics* ]]; then diagnostics fi if [[ $* == *--permission-fix* ]]; then set_permissions fi