# Bash Tab-Completion for OSX Specific commands

I've been looking around and I can't seem to find a bash completion rule set for macOS specific utilities. (i.e. diskutil, kext(*whatever), networksetup, defaults, launchctl, etc.) comparable to tab-completion for git commands.

Specifically, I would like to have TAB print a list of the options for the tool.

Does that exist?

If you use a package manager (Homebrew, MacPorts, etc) it's worth checking if it provides any - brew search completion returns launchctl-completion, for example, though the other tools you mention aren't listed. You don't mention tmutil, but if it's useful there's a completion for it here:

#!/usr/bin/env bash
### 補完関数。
_tmutil(){
list=$( tmutil | /usr/bin/grep -v ^$ | /usr/bin/grep ^Usage | awk '{print $3}' ) COMPREPLY=($(compgen -W "$list"${COMP_WORDS[COMP_CWORD]}  ) )
}
complete -F _tmutil tmutil


That might also be a good basis for hacking your own completions?

• This is awesome. Now if only the different OS X commands' option flags abided a standard format, or had help files as easy to parse as tmutil.. – blanket_cat Apr 9 '17 at 15:44