I have a tool that has a bash completion function installed. One specific flag value that I'm trying to complete requires making an external call to a third party program that is weirdly slow. That's fine, though. It all works. I added some local file caching so users of my tool only need to see this every few days or so.
The problem is that the slowness doesn't seem very user friendly. I don't want the user to have to know how the caching works. Yet, when the cache is dirty, they have to wait ~15 seconds for it to be rebuilt. I want to add something indicating that we're loading this data.
I've tried adding a simple
echo "Querying <third party tool>...", but that interestingly seems to prevent the completion results from actually appearing until I hit tab again (presumably because it only echos that when the cache is dirty and the second time I hit tab reads straight from the cache). I've tried making it echo to stderr instead, but same result.
I'm pretty sure I've seen other tools show loading icons when tab complete is loading. Notably,
gcloud shows it when completing
--project. But I haven't found a sign of how they do it.