3

I'm trying to autocomplete an OS X defaults domain. I type:

$ defaults write <TAB>

And I get lot of results, as you might imagine:

com.apple.AOSNotification.Accounts
com.apple.ATS
com.apple.ActivityMonitor
com.apple.AddressBook
com.apple.AddressBook.abd
com.apple.AddressBookSourceSync
com.apple.Aperture
com.apple.AppleShareClient
com.apple.Automator
com.apple.Automator.LSSharedFileList
com.apple.BezelServices
com.apple.BluetoothAudio
com.apple.CharacterPaletteIM
com.apple.Console
...

Now, normally I might filter this list down by typing the first few letters of what I want and then completing again. Here, though, the interesting part of all of these is at the end of the word. I know the name of the application I'm looking for, which will be near the end of the word, but I'm not sure about the TLD that the full domain starts with (it might be a com, org, net, or something else).

Surely the great zsh has some way to filter this list using a regex or glob, but I can't find it. What's the trick?

3
setopt glob_complete

and perhaps tune other completion-related options. Then type defaults write *foo and press Tab.

| improve this answer | |
  • Do you know if there's a way to make this case insensitive too? (like possible for file names) – slhck May 23 '12 at 21:10
  • @slhck zstyle ':completion:SOMETHING' matcher-list 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}', usually. You need to look at the documentation (i.e. wade through the source) of this command's completion function to find what SOMETHING is. – Gilles 'SO- stop being evil' May 23 '12 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.