Last active
April 30, 2024 12:58
-
-
Save gmolveau/da4e130b346ceb7478e0449094877662 to your computer and use it in GitHub Desktop.
Configure firefox profile with bash cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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