I'm trying to get the profile directory of the default firefox profile (the one that opens automatically) from Bash. How could I proceed? I can't find any useful options issuing
grep 'Path=' ~/.mozilla/firefox/profiles.ini | sed s/^Path=//. Default profile folder name is stored in
profiles.ini. This will work fine while you've got single profile.
If you have more than one Firefox profile then the file format changes, so extracting the folder name becomes more tricky. Here's the script to do that:
#!/bin/bash cd ~/.mozilla/firefox/ if [[ $(grep '\[Profile[^0]\]' profiles.ini) ]] then PROFPATH=$(grep -E '^\[Profile|^Path|^Default' profiles.ini | grep -1 '^Default=1' | grep '^Path' | cut -c6-) else PROFPATH=$(grep 'Path=' profiles.ini | sed 's/^Path=//') fi echo $PROFPATH
This script will work in both cases, it selects the appropriate method depending on the amount of profiles. Works in OSX, too.