List last opened tabs in firefox browser

grep -Eo '"entries":\[{"url":"[^"]*"' "$HOME/.mozilla/firefox/*.default/sessionstore.js" | sed 's/^.*:"//; s/"$//'

1
By: bandie91
2010-08-30 14:30:21

1 Alternatives + Submit Alt

  • Tuned for short command line - you can set the path to sessionstore.js more reliable instead of use asterixes etc. Usable when you are not at home and really need to get your actual opened tabs on your home computer (via SSH). I am using it from my work if I forgot to bookmark some new interesting webpage, which I have visited at home. Also other way to list tabs when your firefox has crashed (restoring of tabs doesn't work always). This script includes also tabs which has been closed short time before.


    2
    F="$HOME/.moz*/fire*/*/session*.js" ; grep -Go 'entries:\[[^]]*' $F | cut -d[ -f2 | while read A ; do echo $A | sed s/url:/\n/g | tail -1 | cut -d\" -f2; done
    b2e · 2009-05-21 21:58:42 0

What Others Think

The 'grep path/to/sessionstore.js sed' by bandi91 does work after these diff: - "\$HOME + "$HOME and replace the joker with the real full path (I eventualy ried every joker combinaison with no luck). Otherwise cool & KISS example.
datruche · 142 weeks and 1 day ago
@datruche You are right, quoted wildcard char does not work. I rather say now: "$HOME"/.mozilla/firefox/*.default/sessionstore.js so quote only "$HOME", not the rest of the path. however quoting HOME variable is almost unneccessary and it is only a habit to avoid whitespace in any shell variable. ad 2nd, you suggest not to escape leading dollar, but I can not see escaped dollar in my snippet.
bandie91 · 142 weeks and 1 day ago
@bandie91, hmm works fine in Firefox: > quote only "$HOME" And for Palemoon if adding 2 jokers: "$HOME"/moon*/pale*/sessionstore.js As for the leading dollar escape I can't remember.
datruche · 137 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: