How to Update Oh My Pi, Plugins, and Skills with a Single Bash Script

When you use Oh My Pi every day for coding and writing, its ecosystem quickly expands: beyond the core OMP binary, you end up with marketplace plugins (like Arsenal), shared skills (like Hallmark), and Git-cloned extensions (like Caveman). The friction shows up at update time—each component relies on a different package manager, and running four separate commands by hand gets old fast.

To keep maintenance simple, I put together a single Bash script that queries every source in sequence, previews what has changed, and lets you decide whether to apply updates step by step or all at once.

What the Script Checks

The script runs four sequential checks across the entire Oh My Pi stack without external dependencies:

  • Oh My Pi Core: compares your installed version against the latest release via npm or omp update.
  • Marketplace Plugins: refreshes registered indexes and checks packages installed through omp plugin.
  • Agent Skills: runs npx skills check to spot newer releases of globally installed skills.
  • Local Git Repositories: scans OMP plugin and skill directories for standalone Git checkouts and fetches any pending upstream commits.

The Complete Script

The script automatically detects your OS locale (English or Italian) and supports three modes: read-only inspection (--dry-run), interactive confirmation, or unattended execution (--yes).

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")"
DRY_RUN=0
AUTO_YES=0

detect_lang() {
  local locale="${LC_ALL:-${LC_MESSAGES:-${LANG:-en}}}"
  case "$locale" in
    it*|IT*) printf 'it' ;;
    *)       printf 'en' ;;
  esac
}
UI_LANG="$(detect_lang)"

msg() {
  if [[ "$UI_LANG" == "it" ]]; then
    printf '%s' "$2"
  else
    printf '%s' "$1"
  fi
}

log_info()  { printf '[INFO]  %s\n' "$*" >&2; }
log_warn()  { printf '[WARN]  %s\n' "$*" >&2; }
log_error() { printf '[ERROR] %s\n' "$*" >&2; }

usage() {
  if [[ "$UI_LANG" == "it" ]]; then
    cat <<EOF
Uso: $SCRIPT_NAME [opzioni]

Verifica, mostra e applica gli aggiornamenti per OMP, plugin marketplace, skill e repo Git locali.

Opzioni:
  -n, --dry-run   Controlla e mostra gli aggiornamenti disponibili senza installarli
  -y, --yes       Applica tutti gli aggiornamenti senza chiedere conferma
  -h, --help      Mostra questo messaggio
EOF
  else
    cat <<EOF
Usage: $SCRIPT_NAME [options]

Check, preview, and apply updates for OMP, marketplace plugins, skills, and local Git plugins.

Options:
  -n, --dry-run   Check and show available updates without installing them
  -y, --yes       Apply all updates without prompting
  -h, --help      Show this help message
EOF
  fi
}

confirm() {
  local prompt="$1"
  if [[ "$DRY_RUN" -eq 1 ]]; then
    return 1
  fi
  if [[ "$AUTO_YES" -eq 1 ]]; then
    return 0
  fi
  local answer=""
  read -r -p "$prompt [y/N]: " answer
  [[ "$answer" =~ ^[YySs]$ ]]
}

check_omp_core() {
  log_info "$(msg "1/4 Checking Oh My Pi core..." "1/4 Controllo Oh My Pi...")"
  if ! command -v omp >/dev/null 2>&1; then
    log_warn "$(msg "'omp' command not found in PATH." "Comando 'omp' non trovato nel PATH.")"
    return
  fi

  local current
  current="$(omp --version 2>/dev/null || echo "unknown")"
  printf '  - %s: %s\n' "$(msg "Installed version" "Versione installata")" "$current"

  if command -v npm >/dev/null 2>&1; then
    local outdated
    outdated="$(npm outdated -g @oh-my-pi/pi-coding-agent 2>/dev/null || true)"
    if [[ -n "$outdated" ]]; then
      printf '%s\n' "$outdated"
      if confirm "$(msg "Update Oh My Pi core now?" "Aggiornare Oh My Pi ora?")"; then
        omp update || npm install -g @oh-my-pi/pi-coding-agent@latest
      fi
    else
      log_info "$(msg "Oh My Pi core is up to date." "Oh My Pi è già aggiornato.")"
    fi
  else
    if confirm "$(msg "Run 'omp update' to check and update OMP?" "Eseguire 'omp update' per verificare e aggiornare OMP?")"; then
      omp update
    fi
  fi
}

check_omp_plugins() {
  log_info "$(msg "2/4 Checking OMP marketplace plugins (e.g. Arsenal)..." "2/4 Controllo plugin marketplace OMP (es. Arsenal)...")"
  if ! command -v omp >/dev/null 2>&1; then
    return
  fi

  omp marketplace update >/dev/null 2>&1 || true
  omp plugin list 2>/dev/null || true

  if confirm "$(msg "Update OMP marketplace plugins?" "Aggiornare i plugin marketplace di OMP?")"; then
    omp plugin update
  fi
}

check_skills() {
  log_info "$(msg "3/4 Checking Agent Skills (e.g. Hallmark)..." "3/4 Controllo Agent Skills (es. Hallmark)...")"
  if ! command -v npx >/dev/null 2>&1; then
    log_warn "$(msg "'npx' not found, skipping skills check." "'npx' non trovato, salto il controllo delle skill.")"
    return
  fi

  local check_out
  check_out="$(npx --yes skills check 2>&1 || true)"
  printf '%s\n' "$check_out"

  if printf '%s' "$check_out" | grep -qiE 'update|outdated|available|→'; then
    if confirm "$(msg "Apply available skill updates?" "Applicare gli aggiornamenti delle skill?")"; then
      npx --yes skills update
    fi
  fi
}

check_git_dirs() {
  log_info "$(msg "4/4 Checking local Git plugins/skills (e.g. Caveman)..." "4/4 Controllo plugin/skill Git locali (es. Caveman)...")"
  local search_roots=(
    "$HOME/.omp/agent/plugins"
    "$HOME/.omp/agent/skills"
    "$HOME/.agents/skills"
  )

  local found_any=0
  for root in "${search_roots[@]}"; do
    [[ -d "$root" ]] || continue
    while IFS= read -r -d '' gitdir; do
      found_any=1
      local repo_dir
      repo_dir="$(dirname "$gitdir")"
      local name
      name="$(basename "$repo_dir")"

      git -C "$repo_dir" fetch --quiet 2>/dev/null || {
        log_warn "$(msg "Cannot fetch $name" "Impossibile verificare $name")"
        continue
      }

      local behind
      behind="$(git -C "$repo_dir" rev-list HEAD..@{u} --count 2>/dev/null || echo "0")"
      if [[ "$behind" -gt 0 ]]; then
        printf '  - %s (%s): %s commit(s) behind\n' "$name" "$repo_dir" "$behind"
        git -C "$repo_dir" log --oneline HEAD..@{u}
        if confirm "$(msg "Pull updates for $name?" "Scaricare gli aggiornamenti per $name?")"; then
          git -C "$repo_dir" pull --ff-only
        fi
      else
        printf '  - %s: %s\n' "$name" "$(msg "up to date" "aggiornato")"
      fi
    done < <(find -L "$root" -maxdepth 2 -name ".git" -print0 2>/dev/null)
  done

  if [[ "$found_any" -eq 0 ]]; then
    log_info "$(msg "No standalone Git repos found in OMP directories." "Nessun repository Git autonomo trovato nelle cartelle OMP.")"
  fi
}

main() {
  while [[ $# -gt 0 ]]; do
    case "$1" in
      -n|--dry-run) DRY_RUN=1; shift ;;
      -y|--yes)     AUTO_YES=1; shift ;;
      -h|--help)    usage; exit 0 ;;
      *)
        log_error "$(msg "Unknown option: $1" "Opzione non riconosciuta: $1")"
        usage >&2
        exit 2
        ;;
    esac
  done

  if [[ "$DRY_RUN" -eq 1 ]]; then
    log_info "$(msg "Running in check-only mode (--dry-run)." "Esecuzione in sola verifica (--dry-run).")"
  fi

  check_omp_core
  printf '\n'
  check_omp_plugins
  printf '\n'
  check_skills
  printf '\n'
  check_git_dirs

  log_info "$(msg "Check completed." "Verifica completata.")"
}

main "$@"

Installation and Usage

1. Save and Make Executable

Save the script as ~/bin/omp-update.sh and grant execute permissions:

mkdir -p ~/bin
chmod +x ~/bin/omp-update.sh

2. Shell Aliases

Add two shortcuts to your ~/.bashrc or ~/.zshrc so you have both a quick status check and an interactive updater ready:

alias omp-check='~/.local/bin/omp-update.sh --dry-run'
alias omp-up='~/.local/bin/omp-update.sh'

Reload your shell configuration with source ~/.bashrc. From then on, run omp-check to inspect pending updates without making changes, omp-up to approve each step interactively, or omp-up -y to update everything in one pass.

Leave a Reply