Consider:
$ ssh fo<tab>
foo fool football
How would I write a for loop to iterate over those values?
#!/usr/bin/env bash
for SERVER in $(ssh fo<MAGIC HERE>) ; do echo $SERVER ; done
The answer should be useful for other completionslist could change regularly, eso hardcoding the values is not an option.g In the specific case of SSH, I understand that I could grep the SSH config file for the matching hosts. But some other completion situations arise, such as:
$ git che<tab>
checkout cherry cherry-pick
The list could change regularly, so hardcoding the values is not an optionanswer should be useful for these other ad-hoc completions as well.