change firefox proxy from terminal How can I change proxy for Firefox from Terminal app? Not the whole computer proxy settings (the ones in Network tab), but just Firefox's.
Here is a shell script I drafted for Mac OS X to use SOCKS, which works okay for me. You can modify it toward your need. For you, you will need to modify values of network.proxy.http and network.proxy.http_port in prefs.js
#!/bin/bash
FIREFOX=&quot;/Applications/Firefox.app/Contents/MacOS/firefox&quot;
PREDIR=&quot;$(ls $HOME/Library/Application\ Support/Firefox/Profiles/ | grep release)&quot;
PREFILE=&quot;prefs.js&quot;
FULLPATH=&quot;$HOME/Library/Application Support/Firefox/Profiles/$PREDIR/$PREFILE&quot;

#IPADDR=&quot;localhost&quot;
#PORT=&quot;7777&quot;
#PROXYTYPE=&quot;1&quot;

IPADDR=&quot;$1&quot;
PORT=&quot;$2&quot;
PROXYTYPE=&quot;$3&quot;

TMPSOCKS=&quot;/tmp/network.proxy.socks.tmp&quot;
TMPSOCKSPORT=&quot;/tmp/network.proxy.socks_port.tmp&quot;


# Insert an ip into firefox for the proxy if there isn't one
if ! grep 'network.proxy.socks\&quot;' &quot;$FULLPATH&quot; 
  then 
    echo &quot;no network.proxy.socks defined&quot;
    echo &quot;no need to save value&quot;
    echo 'user_pref(&quot;network.proxy.socks&quot;, &quot;'&quot;$IPADDR&quot;'&quot;);' &gt;&gt; &quot;$FULLPATH&quot;
    echo 'user_pref(&quot;network.proxy.socks&quot;, &quot;'&quot;$IPADDR&quot;'&quot;);' placed in $FULLPATH
  else 
    echo &quot;network.proxy.socks exists, preserving value ...&quot;
    grep 'network.proxy.socks\&quot;' &quot;$FULLPATH&quot; &gt; &quot;$TMPSOCKS&quot;
    sed -i '' 's/^.*network.proxy.socks&quot;.*$/user_pref(&quot;network.proxy.socks&quot;, &quot;'&quot;$IPADDR&quot;'&quot;);/' &quot;$FULLPATH&quot;
  echo replaced network.proxy.socks to $IPADDR
fi

# Set the port
if ! grep network.proxy.socks_port &quot;$FULLPATH&quot; 
  then 
    echo &quot;no network.proxy.socks_port value defined&quot;
    echo &quot;no need to save value&quot;
    echo 'user_pref(&quot;network.proxy.socks_port&quot;, '''$PORT''');' &gt;&gt; &quot;$FULLPATH&quot; 
    echo 'user_pref(&quot;network.proxy.socks_port&quot;, '''$PORT''');' placed in &quot;$FULLPATH&quot;
  else 
    echo &quot;network.proxy.socks_port found, preserving value ...&quot;
    grep network.proxy.socks_port &quot;$FULLPATH&quot; &gt; $TMPSOCKSPORT
    sed -i '' 's/^.*network.proxy.socks_port.*$/user_pref(&quot;network.proxy.socks_port&quot;, '''$PORT''');/' &quot;$FULLPATH&quot; 
    echo inserted port $PORT to network.proxy.socks_port
fi

# Turn on the proxy
if ! grep network.proxy.type  &quot;$FULLPATH&quot;
  then echo 'user_pref(&quot;network.proxy.type&quot;, '''$PROXYTYPE''');' &gt;&gt; &quot;$FULLPATH&quot; 
  else sed -i '' 's/^.*network.proxy.type.*$/user_pref(&quot;network.proxy.type&quot;, '''$PROXYTYPE''');/' &quot;$FULLPATH&quot; 
fi

# Open Firefox ...
/Applications/Firefox.app/Contents/MacOS/firefox

# After Firefox is closed, need to replace the original value
if [ -f &quot;$TMPSOCKS&quot; ];
    then 
    ORGSOCKS=`cat $TMPSOCKS`
    sed -i '' 's/^.*network.proxy.socks&quot;.*$/'''$ORGSOCKS'''/' &quot;$FULLPATH&quot;
fi
if [ -f &quot;$TMPSOCKSPORT&quot; ];
    then 
    ORGSOCKSPORT=`cat $TMPSOCKSPORT`
    sed -i '' 's/^.*network.proxy.socks_port.*$/'''$ORGSOCKSPORT'''/' &quot;$FULLPATH&quot;
fi

# Turn off the proxy
if ! grep network.proxy.type  &quot;$FULLPATH&quot;
  then echo 'user_pref(&quot;network.proxy.type&quot;, 0);' &gt;&gt; &quot;$FULLPATH&quot;
  else sed -i '' 's/^.*network.proxy.type.*$/user_pref(&quot;network.proxy.type&quot;, 0);/' &quot;$FULLPATH&quot;
fi