Base-Layer AI Integration on Arch Linux With Antigravity CLI

Copying prompts into a browser tab, pasting terminal output back into a web chat, and manually transferring code snippets into an editor is a broken workflow. You burn half your time context-switching while the model stays completely blind to your actual filesystem, environment, and live command output.

When you wire AI directly into the base layer of Arch Linux—inside your window manager keybindings, shell functions, and project directories—it stops being a passive chat box and becomes an overpowered systems tool.


1. Why Base-Layer Integration Beats the Browser

Sitting inside dwm and st, everything happens in text streams and local files. Integrating Gemini and Antigravity CLI (agy) directly into the terminal layer gives you three immediate advantages:


2. Instant Shell Velocity With Alt+G

Half of daily sysadmin and engineering friction isn’t solving hard architectural problems—it’s remembering the exact flag order for find, rsync, awk, tar, openssl, or systemctl when you’re moving fast.

Binding Alt+G right into the keyboard workflow bridges natural language directly into your command line. Instead of breaking focus to search documentation or open a browser for a one-liner, Alt+G lets you generate, verify, and drop exact shell commands straight where you’re already typing—keeping both hands on the home row.


3. Project-Scoped Engineering With Antigravity CLI (agy)

For multi-file tasks—refactoring Hugo templates, debugging Python daemons, or deploying infrastructure—Antigravity CLI (agy) runs natively inside st scoped strictly to the working directory you launch it from (cd ~/Projects/personal_website && agy rather than running wide open from ~).

Inside a session, two slash commands keep cost and reasoning balanced:


4. Dual-Mode Zsh Selector & Dotfile OPSEC

Running a daily CLI workflow hits a real-world constraint fast: subscription quotas (like Google AI Pro) have daily caps, while Google AI Studio API keys give you overflow capacity backed by pay-as-you-go credits.

Instead of manually editing ~/.gemini/antigravity-cli/settings.json or logging out of OAuth every time one quota runs dry, I wrapped agy in a Zsh selector in ~/.zshrc:

[ -f ~/.config/secrets.zsh ] && source ~/.config/secrets.zsh

agy() {
  local f="$HOME/.gemini/antigravity-cli/settings.json"
  local choice
  mkdir -p "${f:h}"

  echo "Select agy mode:"
  echo "  1) Google AI Pro"
  echo "  2) AI Studio API Key (credits)"
  printf "Choice [1/2]: "
  read -r choice

  case "$choice" in
    2)
      if [[ -z "$GEMINI_API_KEY" ]]; then
        echo "Error: GEMINI_API_KEY is not set in ~/.config/secrets.zsh" >&2
        return 1
      fi
      python3 -c "import json,os; p='$f'; d=json.load(open(p)) if os.path.exists(p) else {}; d['modelProvider']='gemini'; json.dump(d,open(p,'w'),indent=2)"
      ;;
    1|"")
      python3 -c "import json,os; p='$f'; d=json.load(open(p)) if os.path.exists(p) else {}; d.pop('modelProvider',None); json.dump(d,open(p,'w'),indent=2)"
      ;;
    *)
      echo "Cancelled."
      return 1
      ;;
  esac

  command agy "$@"
}

Keeping Secrets Out of Public Dotfiles

Because ~/.zshrc is tracked in my public Arch dotfiles repository, GEMINI_API_KEY never touches ~/.zshrc. It lives isolated in ~/.config/secrets.zsh with chmod 600 permissions, sourced conditionally on startup.

By toggling only "modelProvider": "gemini" in settings.json instead of calling /logout, my Google AI Pro OAuth session stays cached—so switching from subscription quota to API credits and back takes a single keystroke.


Wrapping Up

When your AI tooling obeys your shell, keybindings, and security boundaries instead of locking you inside a browser window, it feels less like a chatbot and more like a natural extension of Unix.

Related
Linux · Arch · Zsh · Ai · Automation