Focus-Tab is an AppleScript utility that allows you to quickly open or switch to specific websites in your browser from the command line. It's particularly useful for:
- Workflow automation
- Quick navigation to frequently visited sites
- Scripts and shell aliases for browser-based tools
- Integration with other automation tools
- Chrome-specific tab focusing: When used with Google Chrome, the script will search for existing tabs containing the provided URL and focus them instead of opening duplicate tabs
- Cross-browser support: Works with any browser on macOS (Safari, Firefox, Brave, etc.)
- Simple command-line interface: Just provide a URL and optionally specify the browser
osascript focus-tab.scpt <url> [browser]
# Open or focus Google in Chrome (default browser)
osascript focus-tab.scpt google.com
# Open GitHub in Safari
osascript focus-tab.scpt github.com "Safari"
# Open YouTube in Brave Browser
osascript focus-tab.scpt youtube.com "Brave Browser"
The script has two different behaviors depending on the browser:
-
For Google Chrome: The script will first search through all open windows and tabs for any URL containing the search term. If found, it will focus that tab instead of opening a new one.
-
For other browsers: The script will simply open the URL in a new tab (the tab-finding feature is Chrome-specific due to AppleScript compatibility limitations).
- Create shell aliases for frequently visited sites
- Use as part of more complex automation workflows
- Integrate with hotkeys or keyboard shortcut tools
- Control browser tabs from other applications or scripts
Simply save the focus-tab.scpt
file to a convenient location on your macOS system.
For easier access, you might want to:
- Place it in a scripts directory
- Create a shell alias in your
.zshrc
or.bashrc
file - Integrate with tools like Alfred, Raycast, or Keyboard Maestro