multi-account-containers icon indicating copy to clipboard operation
multi-account-containers copied to clipboard

Container cmdline option when opening URLs

Open pjf opened this issue 7 years ago • 41 comments

Hey lovely devs!

I use containers extensively to separate my personal browsing from the work I do for various clients, and there's one functionality I'd love more than anything else; the ability to specify the container when opening a URL from the command-line. For example:

firefox --container=Work http://example.com/

I'd even be happy with a less-human-friendly version like needing to specify the container by index or uuid, since when I'm opening URLs using the cmdline it's almost always via a helper tool or script.

Thanks again for adding this functionality to Firefox!

~ Paul

pjf avatar Mar 11 '17 06:03 pjf

This likely can't be part of the extension itself however we probably should raise a platform bug to add it there if there is sufficient interest.

jonathanKingston avatar Mar 16 '17 04:03 jonathanKingston

@jonathanKingston : Hooray, thank you!

What's the preferred way to demonstrate there's sufficient interest?

pjf avatar Mar 16 '17 06:03 pjf

We're starting to triage and prioritize based on the number of 👍 these issues get.

groovecoder avatar Mar 16 '17 14:03 groovecoder

By the way, if this gets approved to be added to the Firefox platform itself, it appears to me the way to do it would be to start looking handURIToExistingBrowser - something along the lines of using cmdLine.handleFlagWithParam("container", false) to extract the passed-in container name.

hoelzro avatar Aug 07 '17 19:08 hoelzro

This would be useful in conjunction with my new project https://github.com/mortenn/BrowserPicker In that regard it would be beneficial if the different containers are listed somewhere easy to read, like the windows registry (HKCU). Or indeed if each container was added as a separate browser in the windows registry.

mortenn avatar Aug 15 '17 18:08 mortenn

@mortenn there is already a file for this, however I wouldn't advise using it.

My issue with this is container names may change rapidly and without a programatic way to query these names and IDs then this will likely lead to breakage. An extension could however be added to the browser to convey these changes over nativeMessaging and that would be far more advised than what you are suggesting @mortenn I think.

jonathanKingston avatar Sep 26 '17 00:09 jonathanKingston

BrowserPicker is fairly browser agnostic, so if each container was registered as a separate browser in windows, there would be no need for special handling in BrowserPicker. Other applications looking up browsers in the standard windows way would also benefit, and that would include the default browser picker in windows.

mortenn avatar Dec 17 '18 20:12 mortenn

This feature would be fantastic!

nunofernandes avatar Dec 19 '18 09:12 nunofernandes

I would find this very useful. I want to be able to open a website I'm working on in multiple different containers each with a different user account logged in for testing various workflows.

lindboe avatar Dec 20 '18 00:12 lindboe

Agreed that this is a feature I'd love to have as well.

unity-csang avatar Jan 03 '19 19:01 unity-csang

Even having the ability to open an "anonymous" container that only existed for the duration of the tab - on the command line, would be great. It would provide for some excellent integration into external apps. Or maybe add a way to put it into a URL as well - like https://anonymous+nouser:nopass@url where nouser and nopass don't exist.

bhandeland avatar Jan 23 '19 05:01 bhandeland

While pjf said in his proposal:

I'd even be happy with a less-human-friendly version like needing to specify the container by index or uuid, since when I'm opening URLs using the cmdline it's almost always via a helper tool or script.

it is not true in general case and could lead to obscure errors (like a consequence of a change in the list of defined containers without an appropriate update of indexes in scripts).

As a profile name can be specified in command line the only logical and consistent way to implement this extremely useful feature is to allow to specify the container by its name. Of course, even such a limited solution is better than nothing :-) I would like to have also a way to specify a Temporary Container (like this https://addons.mozilla.org/en-US/firefox/addon/temporary-containers/), probably something what bhandeland proposed in the previous comment.

rakoczy avatar Feb 19 '19 23:02 rakoczy

+1 this request. Loving the containers extension, would love to be able to do things like launch a specific set of sites into specific containers by running one simple script.

JpTiger avatar Mar 18 '19 12:03 JpTiger

This would be great so I could open a new google doc from the command line either for work or personal:

# Google Docs
alias doc="open https://doc.new"
alias sheet="open https://sheet.new"
alias deck="open https://deck.new"

mwarkentin avatar May 10 '19 12:05 mwarkentin

I have a use case where I have assigned multiple cloud accounts to different containers. I use a tool called aws-vault to login to each of these accounts. So if the firefox CLI has an option to pass the container name on which the URL needs to be opened, I can easily write a wrapper to open the different AWS accounts on the specific container, thus saving a lot of time opening a specific container and pasting in the URL

frezbo avatar Jun 12 '19 04:06 frezbo

Came here for the exact same use case as @frezbo

daysofwineandroses avatar Jun 12 '19 15:06 daysofwineandroses

It would be great to get this implemented \o/

lookbeat avatar Jul 31 '19 17:07 lookbeat

Would be very handy since I'm having multiple AWS accounts and links to different accounts need to be open in different containers. Was thinking to alias it but turns out there is no such option...

Andrey9kin avatar Aug 09 '19 12:08 Andrey9kin

It would awesome if this could also work with the -new-tab option. Then on i3/Sway I could make a keyboard shortcut for opening a new tab in a specific container.

rianadon avatar Aug 31 '19 03:08 rianadon

Hello everyone!

I created a separate extension for Firefox to do exactly what we all want in this thread. It might be not the best solution, but it does the job.

The idea is that my extension registers a custom protocol handler (ext+container) to which you can easily pass different parameters (container name and some options in this case) alongside the real URL to be opened through the normal URI you invoke Firefox with. For example, like this: firefox ext+container:name=Github&url=https://github.com

Also I made a shell script to simplify that a bit:

firefox-container -n Github https://github.com

You can install the extension from the official Mozilla repository and also find its source code, launcher script and a quick manual on its Github page.

I am open to your feedback, and I hope you like the extension.

Also I am open to collaborate with the authors of this extension, if they decide it's worth to include such functionality in it.

Have a nice day (or a peaceful night)!

honsiorovskyi avatar Sep 02 '19 00:09 honsiorovskyi

@honsiorovskyi A great of of thanks, I accomplished what I was looking out for with this extension, for anyone this is the aws-vault helper I wrote:

function avl() {
  FIREFOX="/Applications/Firefox.app/Contents/MacOS/firefox"
  LOGIN_URL=$(aws-vault login --stdout "${1}")
  [[ $? != 0 ]] && echo "${LOGIN_URL}" && return
  ENCODED_URL="${LOGIN_URL//&/%26}"
  URI_HANDLER="ext+container:name=${1}&url=${ENCODED_URL}"
  "${FIREFOX}" "${URI_HANDLER}"
}

frezbo avatar Sep 02 '19 12:09 frezbo

I also want to say thank you to @honsiorovskyi ! I have been waiting for something like this for a long time. I can finally set up my password manager to open different accounts on the same site in different containers.

I have groups in KeePass that correspond to the container I want to use. For example, the "Amazon Personal" entry is in the Personal group, and the "Amazon Business" entry is in the Work group. For each entry, under Properties -> Override URL, I set

cmd://{FIREFOX} ext+container:name={GROUP}&url="{URL}"

It works perfectly.

DeronLJ avatar Sep 06 '19 17:09 DeronLJ

This is still an issue that i would like to have as a feature on firefox :)

siozosdr avatar Jul 02 '20 10:07 siozosdr

This is an issue as the only way to get I can credentials/cookies is from CLI, however the only way to have multiple sites open is in Containers, that means one or the other fails unless you can open from the CLI.

michft-v avatar Aug 26 '20 23:08 michft-v

Hello everyone!

I created a separate extension for Firefox to do exactly what we all want in this thread. It might be not the best solution, but it does the job.

Thanks for the "Open external links in a container" addon. I've made a Perl version of your shell script firefox-container [1], with a few minor enhancements: tab completion, opening of multiple URLs, opening of a blank tab if URL is not specified.

[1] https://metacpan.org/pod/firefox-container

perlancar avatar Sep 21 '20 10:09 perlancar

We're starting to triage and prioritize based on the number of +1 these issues get.

Hey, after 224 :+1: and 3+ years has this Feature been prioritized anywhere or since @honsiorovskyi (thank you sir!) has proposed his implementation you're not going to do anything?

Because would also be nice if this could work with Site-Specific Browser (--ssb) as well...

andreamtp avatar Oct 07 '20 15:10 andreamtp

Having native support for this would be fantastic. Just expressing my interest even if this thread is now dead and buried. 👍🏼

livmackintosh avatar Jul 04 '21 22:07 livmackintosh

Would be awesome to see this feature added. Automating workflows would be far easier with this natively supported

philippatelis avatar Sep 03 '21 20:09 philippatelis

At the same page. This is a very requested feature

rifaterdemsahin avatar Oct 11 '21 07:10 rifaterdemsahin

More than 4 years waiting for this useful feature 😞

Please, guys... I understand that UI is good for "most of the people", but don´t forget the CLI... I'm sure its as useful (or more) than the UI for a lot of us..

bhean avatar Oct 11 '21 15:10 bhean