A Mac CLI for herding browser tabs. Pure zsh + JXA, no dependencies.
# Clone and add to PATH
git clone git@github.com:yy/tabby.git ~/git/tabby
export PATH="$HOME/git/tabby/bin:$PATH"tabby list # List all tabs as JSON
tabby list --window 1 # List tabs in window 1
tabby count # Count tabs per window
tabby count --total # Just the total
tabby url # URL of active tab
tabby url 1 3 # URL of window 1, tab 3
tabby close 1 5 # Close window 1, tab 5
tabby close --url arxiv # Close first tab whose URL contains "arxiv"
tabby focus 1 3 # Switch to window 1, tab 3
tabby dedup # Close duplicate tabs
tabby dedup --dry-run # Preview duplicates
tabby version # Print version (also --version, -v)
Composes with standard tools:
# Find all GitHub tabs
tabby list | jq '.[] | select(.url | test("github.com"))'
# Count tabs per domain
tabby list | jq -r '.[].url' | awk -F/ '{print $3}' | sort | uniq -c | sort -rn
# Close all Google search tabs (careful!)
tabby close --url "google.com/search" --alltabby --browser safari list # Use Safari
TABBY_BROWSER=safari tabby list # Same, via env varDefault: chrome. Set TABBY_BROWSER=safari in your shell profile to switch permanently.
Tab indices shift when tabs are closed, and browsers reorder windows by recency between calls, so a window/tab index read from list can point at a different tab by the time you close it. Two ways to close safely:
tabby close --expect "GitHub" 1 5 # Only closes if title starts with "GitHub"
tabby close --url github.com/foo # Find + close by URL in one step (no index race)
tabby close --url github.com --all # Close every matching tabPrefer --url in scripts: it resolves the tab and closes it inside a single call, so window reordering can't make it hit the wrong tab.
--url matches on substring and, without --all, closes the first hit. That bites when your needle is a prefix of another open tab's URL: https://bsky.app/ also matches https://bsky.app/profile/someone/post/123. Narrow it:
tabby close --url https://bsky.app/ --exact # Whole URL must equal the needle
tabby close --url bsky.app --expect "Quiet" # URL hit must also pass the title check--exact and --expect compose, and both abort rather than close a tab they can't confirm.
On first run, macOS will prompt you to grant your terminal Automation access to Chrome (or Safari). This allows tabby to read tab titles/URLs and close tabs. You can revoke this in System Settings > Privacy & Security > Automation.
tabby list outputs all tab titles and URLs to stdout. Be mindful when piping to files or logs — URLs may contain tokens, session IDs, or reveal private browsing activity.
- macOS
- Google Chrome or Safari