Get sharing link in terminal


I’m looking for a way to share a Google Drive file using the terminal. I can do it from the UI or from my file explorer, but as I am doing this very often, and for automation purposes, it would be great to have a CLI command for this. Maybe something like :
insync share --private /linkToDriveFolder/file.txt

Then I could copy the link in my clipboard with

insync share --private /linkToDriveFolder/file.txt | xclip

I found the open-share-dialog command but it doesn’t seem to work on my machine.

It would really accelerate my workflow.

Thanks !

hey! thanks for the request.

how would you add this for automation purposes?
are there other automation you would like to see (app or headless)?



Hello, thanks for your fast answer !

I use for a lot of tasks, but I rely on Google drive to store my files. Notion provides a nice way of including google drive items in the notes. And the fastest way of doing that is by pasting the Google drive file’s link directly in Notion.
So I’m looking for the fastest way to get the link for a file. A terminal command would work well for this, because I could set up an alias for it.

I often have to scan pages, merge some pdf files, remove white borders, add chapters, compress them and add a notion page. All this can be automated, except for getting the file/folder 's link. (Something could be done using the Google drive’s api, but the best would be to integrate this feature directly in Insync)

If I was asked the specifications :

  • share files and whole folders

  • by default, the link created must be a “private link”. ( Possessors of the link can access de document only if they were granted by the document owner)

  • the -s --share flag makes a “public link”, anyone having the link can access the document.

To facilitate automation :

  • the link should be written on stdout with no extraneous content, except when -v flag is used. On success, should exit with 0 status code

  • if an error occurs, the message should be written on stderr and the exit code is not 0.

A feature that I would sometimes use :
When creating a “private link” :

  • the -e --email option, followed by one or many email addresses allows the user to share the document with specific people.

Also, if possible, the unshare command would be used to revert the sharing of a document.

This is obviously an example, and probably how I’d implement it.

I don’t see any other automation for the moment, Insync has already a lot of the features I was looking for. Thanks for this product.

I’d be happy to contribute on this feature, let me know if you need anything :slight_smile: