Skip to content

Instantly share code, notes, and snippets.

@zonca
Last active May 14, 2026 04:02
Show Gist options
  • Select an option

  • Save zonca/9a782adfefe29af8d68558b206517f64 to your computer and use it in GitHub Desktop.

Select an option

Save zonca/9a782adfefe29af8d68558b206517f64 to your computer and use it in GitHub Desktop.
AI Tools Updater - Shell function to update all AI coding assistants at once

AI Tools Updater

A shell function that updates all your AI coding assistants and tools in one command.

Features

• Updates multiple AI coding tools via npm and native CLI commands
• Shows before/after version comparison for all tools
• Handles both npm packages and standalone CLI tools
• Supports apt system package upgrades

Supported Tools

Tool │ Package │ Description
────────────────────────────────────┼────────────────────────────────────┼───────────────────────────────────
Qwen Code │ @qwen-code/qwen-code │ Alibaba's AI coding assistant
Cline │ cline │ Autonomous coding agent
Claude │ claude (CLI) │ Anthropic's Claude Code
Gog │ gog (CLI) │ Google Workspace CLI
Gemini CLI │ @google/gemini-cli │ Google's AI assistant
Codex │ @openai/codex │ OpenAI's code model
Crush │ @charmland/crush │ AI coding tool
OpenCode AI │ opencode-ai │ AI code generator
Bitwarden │ @bitwarden/cli │ Password manager CLI
GitHub Copilot │ @github/copilot │ GitHub AI pair programmer

Installation

Add the up() function to your ~/.bashrc or ~/.bash_aliases :

# Clone or copy the up.sh content                                                                            
curl -o ~/.up.sh https://gist.githubusercontent.com/zonca/9a782adfefe29af8d68558b206517f64/raw/up.sh         
                                                                                                             
# Add to your shell config                                                                                   
echo 'source ~/.up.sh' >> ~/.bashrc                                                                          
source ~/.bashrc                                                                                             

Usage

Run the up command to update all tools:

up                                                                                                           

Customization

Edit the npm_pkgs array in the function to add or remove packages:

local npm_pkgs=("@google/gemini-cli" "@openai/codex" "opencode-ai" "@charmland/crush" "@qwen-code/qwen-code" 

"cline" "@bitwarden/cli" "@github/copilot")

Requirements

• Node.js/npm (for npm packages)
• curl/wget (for installation)
• gh CLI (for gogcli updates)

License

MIT

up() {
local npm_pkgs=("@google/gemini-cli" "@openai/codex" "opencode-ai" "@charmland/crush" "@qwen-code/qwen-code" "cline" "@bitwarden/cli" "@github/copilot")
local installed_npm=()
declare -A old_vers
echo "Checking current versions..."
for p in "${npm_pkgs[@]}"; do
local version=$(npm list -g "$p" --depth=0 2>/dev/null | grep "$p" | rev | cut -d@ -f1 | rev || echo "")
if [ -n "$version" ] && [[ "$version" != *"empty"* ]]; then
installed_npm+=("$p")
old_vers["npm:$p"]="$version"
fi
done
if command -v gog >/dev/null 2>&1; then
old_vers["gog"]=$(gog version | head -1 | awk "{print \$2}")
fi
if command -v claude >/dev/null 2>&1; then
old_vers["claude"]=$(claude --version 2>/dev/null | head -1 || echo "N/A")
fi
echo "Fetching apt upgrade info..."
sudo apt update > /dev/null
local apt_upgradable=$(apt list --upgradable 2>/dev/null | grep "/")
echo "Starting system and package updates..."
sudo apt upgrade -y
if [ ${#installed_npm[@]} -gt 0 ]; then
echo "Updating npm packages: ${installed_npm[*]}"
local prefix=$(npm config get prefix)
sudo rm -rf "$prefix/lib/node_modules/@google/.gemini-cli-*" "$prefix/lib/node_modules/.codex-cli-*"
sudo npm install -g "${installed_npm[@]}" --force
fi
if command -v gog >/dev/null 2>&1; then
echo "Updating gogcli..."
local temp_dir=$(mktemp -d)
local arch="amd64"
[ "$(uname -m)" = "aarch64" ] && arch="arm64"
if gh release download --repo openclaw/gogcli --pattern "*linux_${arch}.tar.gz" --dir "$temp_dir"; then
tar -xzf "$temp_dir"/*linux_${arch}.tar.gz -C "$temp_dir"
local gog_path=$(which gog)
sudo mv "$temp_dir/gog" "$gog_path"
sudo chmod +x "$gog_path"
echo "gogcli updated successfully at $gog_path"
else
echo "Failed to download gogcli release."
fi
rm -rf "$temp_dir"
fi
if command -v claude >/dev/null 2>&1; then
claude upgrade 2>/dev/null || true
fi
if command -v copilot >/dev/null 2>&1; then
copilot extension upgrade 2>/dev/null || true
fi
echo -e "\n--- Update Report ---"
printf "%-30s | %-15s -> %-15s\n" "Package" "Old" "New"
echo "------------------------------------------------------------------------"
if [ -n "$apt_upgradable" ]; then
while read -r line; do
local pkg_name=$(echo "$line" | cut -d/ -f1)
local old_v=$(echo "$line" | awk "{print \$6}" | tr -d "[]")
local new_v=$(echo "$line" | awk "{print \$2}")
printf "%-30s | %-15s -> %-15s\n" "apt:$pkg_name" "$old_v" "$new_v"
done <<< "$apt_upgradable"
fi
for p in "${installed_npm[@]}"; do
local new_v=$(npm list -g "$p" --depth=0 2>/dev/null | grep "$p" | rev | cut -d@ -f1 | rev || echo "N/A")
printf "%-30s | %-15s -> %-15s\n" "npm:$p" "${old_vers["npm:$p"]}" "$new_v"
done
if command -v gog >/dev/null 2>&1; then
local new_gog=$(gog version | head -1 | awk "{print \$2}")
printf "%-30s | %-15s -> %-15s\n" "gog" "${old_vers["gog"]}" "$new_gog"
fi
if command -v claude >/dev/null 2>&1; then
local new_claude=$(claude --version 2>/dev/null | head -1 || echo "N/A")
printf "%-30s | %-15s -> %-15s\n" "claude" "${old_vers["claude"]}" "$new_claude"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment