forked from cowboy/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_firefox
executable file
·58 lines (50 loc) · 1.77 KB
/
multi_firefox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
if [[ "$1" == "-h" || "$1" == "--help" ]]; then cat <<HELP
Multi-Firefox Fixer
http://benalman.com/
Usage: $(basename "$0")
Run this shell script to "fix" all /Applications/Firefox*.app to always use an
app-named profile. For example, if an application is named "Firefox Beta.app"
then the "Firefox Beta" profile will always be loaded when that application is
run. This allows multiple versions of Firefox to be open simultaneously.
Note that upon first run of a "fixed" Firefox, an app-named profile will need
to be created. This can be done in the dialog that Firefox displays, just be
sure to name it correctly!
Copyright (c) 2012 "Cowboy" Ben Alman
Licensed under the MIT license.
http://benalman.com/about/license/
HELP
exit; fi
apps=()
shopt -s nullglob
for ff in /Applications/Firefox*.app; do apps=("${apps[@]}" "$ff"); done
if (( ${#apps[@]} == 0 )); then
echo "ERROR: No Firefox*.app apps found in /Applications."
echo "For usage instructions, run: $(basename "$0") -h"
exit 1
fi
for ff in "${apps[@]}"; do
bin_path="$ff/Contents/MacOS"
bin="firefox"
[[ -e "$bin_path/$bin" ]] || bin="firefox-bin" # legacy, <= 3.6
echo "Fixing $ff"
if [[ ! "$(file "$bin_path/$bin" | grep 'shell script')" ]]; then
echo -ne " \033[1;33m➜\033[0m "
echo "Backing up $bin executable to firefox.bin (first run only)."
mv "$bin_path/$bin" "$bin_path/firefox.bin"
fi
echo -ne " \033[1;32m✔\033[0m "
if [[ -f "$bin_path/$bin" ]]; then
echo "Updating $bin script."
else
echo "Creating $bin script."
fi
cat > "$bin_path/$bin" <<'BASH'
#!/bin/bash
bin="$(echo $0 | perl -pe's/-bin$//;s/$/.bin/')"
profile="$(echo $0 | perl -ne'm#/(Firefox[^/]*)\.app/# && print $1')"
"$bin" -P "$profile"
BASH
chmod +x "$bin_path/$bin"
done
echo -e "\nAll done!"