im_wower
·
2026-03-22
open-firefox-with-plugin.sh
1#!/usr/bin/env bash
2set -euo pipefail
3
4usage() {
5 cat <<'EOF'
6Usage:
7 scripts/firefox/open-firefox-with-plugin.sh [options]
8
9Options:
10 --firefox-app PATH Firefox.app path. Defaults to /Applications/Firefox.app
11 --url URL Optional URL to open after launch.
12 --wait Wait for the `open` command to finish.
13 --help Show this help text.
14
15Notes:
16 This launcher now opens the system Firefox with its normal default profile.
17 The baa-firefox extension is expected to be installed manually in that profile.
18 Keep Firefox running as a normal long-lived process.
19EOF
20}
21
22firefox_app="/Applications/Firefox.app"
23open_url=""
24wait_flag="0"
25
26while [[ $# -gt 0 ]]; do
27 case "$1" in
28 --firefox-app)
29 firefox_app="$2"
30 shift 2
31 ;;
32 --url)
33 open_url="$2"
34 shift 2
35 ;;
36 --wait)
37 wait_flag="1"
38 shift
39 ;;
40 --help)
41 usage
42 exit 0
43 ;;
44 *)
45 printf '[firefox] error: unknown option: %s\n' "$1" >&2
46 exit 1
47 ;;
48 esac
49done
50
51[[ -d "$firefox_app" ]] || {
52 printf '[firefox] error: missing Firefox.app: %s\n' "$firefox_app" >&2
53 exit 1
54}
55
56cmd=(open -a "$firefox_app")
57
58if [[ "$wait_flag" == "1" ]]; then
59 cmd+=(-W)
60fi
61
62if [[ -n "$open_url" ]]; then
63 cmd+=("$open_url")
64fi
65
66printf '[firefox] app: %s\n' "$firefox_app"
67printf '[firefox] mode: system default profile\n'
68if [[ -n "$open_url" ]]; then
69 printf '[firefox] url: %s\n' "$open_url"
70fi
71printf '[firefox] extension: install baa-firefox manually in the normal Firefox profile\n'
72
73exec "${cmd[@]}"