maxheld83 / byod

make life easier with r projects and docker
MIT License
0 stars 0 forks source link

copy local port url to clipboard (for use in browser) #11

Open maxheld83 opened 5 years ago

maxheld83 commented 5 years ago

that might be a halfway-point to #10

Ch1pzZz commented 5 years ago

https://unix.stackexchange.com/questions/241658/is-there-a-way-to-get-the-url-from-current-tab-in-google-chrome

Looks like someone has had that issue. We might be able to reuse the given code here and give it a try.

maxheld83 commented 5 years ago

ah sorry, my original issue title was a bit misleading; we're actually looking for copying the other way around here – we want to get the local host url localhost::8080 emitted from the script into the clipboard, so people can quickly copy paste it into their browser.

So we need a little CLI tool which allows us to write stuff to the clipboard.

Ch1pzZz commented 4 years ago

I found the tool xclip in a couple of articles regarding the subject so maybe that one is worth a try.

https://superuser.com/questions/370160/manipulate-system-clipboard-via-bash-script

maxheld83 commented 4 years ago

yes, it seems like xclip is the ticket! Unfortunately, it would only work on unix-es (Linux, macOS), but so would the docker call, so that's quite something.

One way to go about this would be to build a small wrapper function around the docker run call here, and have its emitted local host url directly piped to xclip.

Come to think of it, it might be better of this were an option – overwriting the clipboard is potentially destructive (it would presumably overwrite whatever is in the current clipboard) and uncommon for apps, so it might cause some frustration as a default.

So maybe this a bit too risky.