Skip to content
Find file
c8002bf Sep 26, 2013
executable file 59 lines (50 sloc) 1.77 KB
#!/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!"
Something went wrong with that request. Please try again.