Skip to content

Instantly share code, notes, and snippets.

@gwuah
Created February 26, 2026 12:31
Show Gist options
  • Select an option

  • Save gwuah/f492d33d7bfc6295c8b7da762433d91b to your computer and use it in GitHub Desktop.

Select an option

Save gwuah/f492d33d7bfc6295c8b7da762433d91b to your computer and use it in GitHub Desktop.
Accra
Kumasi
Tamale
Sekondi
Ashaiman
Sunyani
Cape
Obuasi
Teshie
Tema
Madina
Koforidua
Wa
Techiman
Ho
Nungua
Lashibi
Dome
Tema
Gbawe
Kasoa
Ejura
Taifa
Bawku
Aflao
Agona
Bolgatanga
Tafo
Berekum
Nkawkaw
Akim
Winneba
Hohoe
Yendi
Suhum
Kintampo
Adenta
Nsawam
Mampong
Konongo
Asamankese
Wenchi
Savelugu
Agogo
Anloga
Prestea
Effiakuma
Tarkwa
Elmina
Dunkwa
Begoro
Kpandu
Navrongo
Axim
Apam
Salaga
Saltpond
Akwatia
Shama
Keta
Nyakrom
Bibiani
Somanya
Assin
Nyankpala
Aburi
Mumford
Bechem
Duayaw
Kade
Anomabu
Akropong
Kete
Kibi
Kpandae
Mpraeso
Akim
Aboso
Bekwai
Drobo
Banda
Dodowa
Larteh
Tumu
Goaso
@gwuah
Copy link
Author

gwuah commented Feb 26, 2026

#!/usr/bin/env bash
set -euo pipefail

AGENTS_DIR="$HOME/Desktop/agents"
CITIES_FILE="$AGENTS_DIR/cities.txt"
SESSION="agents"

# Collect taken window names (lowercase) if session exists
taken=()
if tmux has-session -t "$SESSION" 2>/dev/null; then
  while IFS= read -r name; do
    taken+=("$name")
  done < <(tmux list-windows -t "$SESSION" -F "#{window_name}")
fi

# Pick a random unused city
available=()
while IFS= read -r city; do
  [[ -z "$city" ]] && continue
  lower="$(echo "$city" | tr "[:upper:]" "[:lower:]")"
  skip=false
  for t in "${taken[@]+"${taken[@]}"}" ; do
    if [[ "$t" == "$lower" ]]; then
      skip=true
      break
    fi
  done
  if [[ "$skip" == false ]]; then
    available+=("$lower")
  fi
done < "$CITIES_FILE"

if [[ ${#available[@]} -eq 0 ]]; then
  echo "No cities left. All agents are running."
  exit 1
fi

# Pick random
city="${available[RANDOM % ${#available[@]}]}"

# Create working directory
mkdir -p "$AGENTS_DIR/$city"

# Create or extend tmux session
if tmux has-session -t "$SESSION" 2>/dev/null; then
  tmux new-window -t "$SESSION" -n "$city" -c "$AGENTS_DIR/$city"
else
  tmux new-session -d -s "$SESSION" -n "$city" -c "$AGENTS_DIR/$city"
fi

# Launch claude in the window
tmux send-keys -t "$SESSION:$city" "claude --permission-mode acceptEdits" Enter

# Accept the workspace trust prompt
tmux send-keys -t "$SESSION:$city" Enter

# Attach or switch
if [[ -n "${TMUX:-}" ]]; then
  tmux switch-client -t "$SESSION"
else
  tmux attach -t "$SESSION"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment