Permalink
Browse files

Adding bin/multi_firefox Fult-Firefox Fixer. Yay.

  • Loading branch information...
1 parent a740eaa commit bc588a4682053fe6ef63f540a2573418cff164c8 @cowboy committed Jan 2, 2012
Showing with 58 additions and 0 deletions.
  1. +58 −0 bin/multi_firefox
View
@@ -0,0 +1,58 @@
+#!/bin/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!"

0 comments on commit bc588a4

Please sign in to comment.