2

From bash, I would like a command (or function) that I can use to get a list (one per line) of URLs that are currently opened in a Chromium window.

I have seen a similar question here, but I think it requires creating an extension? If creating extension is only way, can you please give explicit instructions (ideally a bash script that creates the required extension)?

Community
  • 1
  • 1
Xu Wang
  • 10,199
  • 6
  • 44
  • 78
  • Possible duplicate of [Retrieving which tabs are open in Chrome?](http://stackoverflow.com/questions/11915370/retrieving-which-tabs-are-open-in-chrome) – Skrat Feb 21 '16 at 03:03
  • This works well on Mac: https://github.com/prasmussen/chrome-cli – Will Feb 21 '16 at 05:26
  • @Skrat I do not believe it is a duplicate. That question does not mention Bash. – Xu Wang Feb 21 '16 at 05:42
  • @Will nice find. that would be nice. Unfortunately I am on Ubuntu. – Xu Wang Feb 21 '16 at 05:43
  • @XuWang Did you [see this answer](http://stackoverflow.com/a/11915443/316622)? It states an extension is the only way and I doubt anyone is going to do your work for you by creating that extension, especially a bash script that will create that extension. – Skrat Feb 21 '16 at 17:41
  • @Skrat thank you, yes I have read that answer. I think it is 6 years ago and Chromium development is quite rapid so I am guessing many things have changed. – Xu Wang Feb 23 '16 at 02:51
  • An extension is not the only way. See [this answer](https://askubuntu.com/a/970586/167115). It may take some slight modification. The directories were different. I had to use the Sessions directory and in that directory there was a file that begins with `Tab` for each active session. Also, I had to change `chromium` to `google-chome` of course. For example, on Chrome I had to use this instead `cat -e ~/.config/google-chrome/Default/Sessions/Tab* | sed -e 's/\^@/\n/g' -e '/_\/chrome/d' | grep http | sort -u | sed 's/http/\nhttp/g' | perl -pe 's|(?<!/)/[^/]*$|/|'` – mchid Mar 04 '22 at 14:25
  • I used the extra `sed` and `perl` commands at the end to clean up the output a bit and truncate some of the really long URLs and I think I removed something in the middle and added `grep http`. – mchid Mar 04 '22 at 14:27

0 Answers0