I use a simple bash alias to keep my environment in sync with one command. It handles standard system updates and refreshes my core AI tools—the Gemini and Codex CLIs.
To keep the process smooth, the script includes a quick cleanup of temporary directories, which helps avoid those common ENOTEMPTY rename errors that can occasionally stall npm global updates.
The Alias
Add this to your .bashrc or .zshrc:
alias up="sudo apt update && sudo apt upgrade -y && rm -rf \$(npm config get prefix)/lib/node_modules/@google/.gemini-cli-* \$(npm config get prefix)/lib/node_modules/.codex-cli-* && npm install -g @google/gemini-cli codex-cli"How it works:
- System: Runs
apt updateandupgrade. - Cleanup: Dynamically finds your npm path and clears stale temporary folders.
- Tools: Reinstalls the latest versions of
@google/gemini-cliandcodex-cli.
You can find the full version and implementation notes here: