Get internal link for a file in Nextcloud from a local command line

Is there a way to get the internal link for a sync’d file from the command line? From a client, I mean, not using occ on the server.

Something like:

$ ls ~/Nextcloud

$ nextcloud-cli internal-link ~/Nextcloud/foo.txt

I often want to refer to a sync’d file in Talk or an email. I don’t want to create new share links, I want to use the canonical/permalink for a file since the people I’m sharing with already have access.

I have the Nextcloud desktop app running, so I can get the internal link from the Files app (aka Nautilus). I can also get this internal link from the sharing sidebar in the web browser, I’m just looking for a way to avoid several mouse clicks/movements in either. (A Nextcloud cli client tool/method would be handy for other kinds of automation, too.)

Another related idea is that perhaps the URL displayed in the web browser address bar should actually be the internal link, since that’s the only portable / canonical / permalink to a file in Nextcloud, as far as I can tell.

I wrote this. Feedback welcome!