Rclone remote path auto-completion on Linux (Google Drive)

I started playing with rclone in the interest of easily editing files from Google Drive with Vim. As it turns out, you can’t edit native Google Docs files in this manner, so that was a wash!

But a side benefit of this misadventure is this bash autocomplete script which I wrote to auto-complete remote paths for rclone with a Google Drive target. It probably works for others too, I haven’t tested them. 🙂

This implementation is in pure bash all except for the call to rclone itself to check against known remote targets. I appreciated An introduction to bash completion to get me started on the concepts, and the rest of what anyone needs is all in the bash manpage under complete.

Here in this post is the initial version I’m using. If you’re going to use it, check the current version of the file on my Github in case anything changes.