Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If Google Chrome and Firefox are both running, is there any way to transfer all browser tabs from Firefox to Google Chrome? I want to write a shell script that will transfer all tabs from Firefox to Google Chrome on Ubuntu.

share|improve this question
    
A related question: stackoverflow.com/questions/3674633/… –  Anderson Green Jan 3 '13 at 5:55
1  
If you want to do the reverse of this (transferring the tabs from Google Chrome to Firefox), then the following question may be useful: stackoverflow.com/questions/4968271/… –  Anderson Green Jan 3 '13 at 5:58
    
To open the page http://www.facebook.com/ in a new Chrome tab, you would use the following command: google-chrome http://www.facebook.com. –  Anderson Green Jan 3 '13 at 6:01
add comment

2 Answers

Following the idea given in the comments (getting the links from the sessionrestore.js file in the FF profile dir), here is a Bash script with embedded Python to open the current tabs in Google Chrome:

google-chrome $(cat ~/.mozilla/firefox/*.default/sessionstore.js | python -c """
import sys, json
jsobj = json.loads(sys.stdin.read())
for tab in jsobj['windows'][0]['tabs']:
        print tab['entries'][0]['url'],
        """)

Please note that although the script works alright, it isn't verifying anything. But a more robust version of this would check the existence of file sessionrestore.js, verify the result of loading the JSON file and its contents, and so on.

share|improve this answer
    
This looks interesting, thanks. What do you mean when you say that the script isn't verifying anything? –  Anderson Green Jan 8 '13 at 0:24
1  
I mean it does not verifies if the file sessionrestore.js exists, before trying to load. A more robust script would first check if the file exists, something like [ -f PATH/TO/sessionrestore.js ] || { echo "sessionrestore not found!"; exit 1; }, things like this. –  elias Jan 8 '13 at 0:30
add comment

Install the Xmarks extension on both Firefox and Chrome. Besides synchronizing your bookmarks across the browsers you'll be able to use the function "Open remote tabs" which does precisely what you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.