balta2ar / brotab

Control your browser's tabs from the command line
MIT License
389 stars 27 forks source link

Question: how do I use "query" functionality from terminal? #103

Closed mailsanchu closed 11 months ago

drocta commented 11 months ago

Have you tried brotab query --help? It gives a list of the arguments you can use with it, and generally how to use them.

Does this answer your question? If not, can you be more specific?

mailsanchu commented 11 months ago

I am trying to find a url and activate it. I can use it. Using grep. bt list | grep "facebok.com" |awk -F ' ' '{print $1}'

Can we do this using brotab without using grep and awk

drocta commented 11 months ago

It should be possible to not have the grep step. I'm not really familiar with awk, so I'm not sure what that step is doing. I believe this query should work for the part before the second pipe in your bash line there : brotab query -url *://*.facebook.com/*

I believe the pages https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/Tabs/query and https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns document the "tabs.query" api and the "match patterns" for urls that are used in it.

Edit: Note that if you have multiple tabs open on facebook.com , this will list multiple tabs, each on its own line.

mailsanchu commented 11 months ago

awk is spliting the output by space and getting the tab id. Is it possible only to get the tab id in the output?

drocta commented 11 months ago

I don't know of a way to do that with just brotab. Personally, I use cut for that, instead of awk.

Actually, I'm pretty sure that the brotab command line program receives the information in that format when it receives it from the browser extension. It isn't doing that itself. So, in order for it to give you the split version, it would have to do the splitting itself. Which, it could, but I don't think there is an option for that at present.

mailsanchu commented 11 months ago

That is perfectly fine. Closing the ticket

mailsanchu commented 11 months ago

Last question Can we get multiple domains using query like facebook or github? brotab query -url *://*.facebook.com/*

drocta commented 11 months ago

Yup! brotab query -url *://*.facebook.com/* -url *://*.github.com/* will search for tabs satisfying either url condition