Get the default Firefox profile directory from bash
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 firefox --help
Solution 1:
Try 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.
Solution 2:
Your default profile directory is stored under home directory.
cd ~/.mozilla/firefox
Here you will find something like xxxxxxxx.default. This is the location where all your personal data is stored.
You can run the command firefox -P
to show the profiles available and select one from the list.
Solution 3:
I know that this a little older, but in case someone else also needs this information, here is how I set the default profile variable in a wrapper script for firefox:
def_Pfile=`cat "$HOME/.mozilla/firefox/profiles.ini" | sed -n -e 's/^.*Path=//p' | head -n 1`
Hope this helps, as it works for me.