Skip to content
This repository
Browse code

Adding bin/multi_firefox Fult-Firefox Fixer. Yay.

  • Loading branch information...
commit bc588a4682053fe6ef63f540a2573418cff164c8 1 parent a740eaa
Ben Alman authored

Showing 1 changed file with 58 additions and 0 deletions. Show diff stats Hide diff stats

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

0 comments on commit bc588a4

Please sign in to comment.
Something went wrong with that request. Please try again.