Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active April 30, 2024 12:58
Show Gist options
  • Save gmolveau/da4e130b346ceb7478e0449094877662 to your computer and use it in GitHub Desktop.
Save gmolveau/da4e130b346ceb7478e0449094877662 to your computer and use it in GitHub Desktop.
Configure firefox profile with bash cli
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
if [ -d "${HOME}/.mozilla/firefox" ]; then
FIREFOX_PROFILES="${HOME}/.mozilla/firefox"
elif [ -d "${HOME}/snap/firefox/common/.mozilla/firefox" ]; then
FIREFOX_PROFILES="${HOME}/snap/firefox/common/.mozilla/firefox"
fi
PROFILES_INI="${FIREFOX_PROFILES}/profiles.ini"
if grep -q '\[Profile[^0]\]' "${PROFILES_INI}"; then
PROFILE_PATH=$(grep -E '^\[Profile|^Path|^Default' "${PROFILES_INI}" | grep -1 '^Default=1' | grep '^Path' | cut -c6-)
else
PROFILE_PATH=$(grep 'Path=' "${PROFILES_INI}" | sed 's/^Path=//')
fi
PROFILE_PATH="${FIREFOX_PROFILES}/${PROFILE_PATH}"
USER_PREFS="${PROFILE_PATH}/prefs.js"
touch "${USER_PREFS}"
cat << 'EOF' >> "${USER_PREFS}"
# don't trim URLs
user_pref("browser.urlbar.trimURLs", "false");
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment