zsh-users
 help / color / mirror / code / Atom feed
* Re: Completion functions for Mac OS X
       [not found] ` <5F375244-DBDD-11D8-8A54-000D93502E64@h8.dion.ne.jp>
@ 2005-01-15 16:59   ` lists
  2005-01-16 16:08     ` Motoi Washida
  0 siblings, 1 reply; 3+ messages in thread
From: lists @ 2005-01-15 16:59 UTC (permalink / raw)
  To: zsh-users; +Cc: Motoi Washida

Motoi,
	Thanks so much for putting these (and other Darwin) completions 
together.  Could I make a small feature request for the _defaults 
completion?  Sometimes I use defaults(1) to read plist files which 
aren't part of a registered domain.  For example:

defaults read /Applications/TextEdit.app/Contents/Info

will normally display the contents of 
/Applications/TextEdit.app/Contents/Info.plist

If I use the _defaults completion, this doesn't work (and neither does 
TAB completion: 'defaults read /App<TAB>').  Could _defaults be 
modified to allow for viewing of xml files which aren't registered as a 
defaults domain?  I'd love to help but haven't been able to get the 
hang of writing completions yet.

Thanks,
Ryan


On Jul 22, 2004, at 7:48 AM, Motoi Washida wrote:

> Here are the scripts. I also have another script (hdiutil), though it 
> is
> not completed yet.
>
> On 2004/07/22, at 19:57, Motoi Washida wrote:
>
>> Hi all,
>>
>> Did anyone whotre completion scripts for commands on Mac OS X? I 
>> couldn't
>> find such scripts, so I wrote some scripts. But I found someone tried 
>> to
>> do the same thing on this list today.
>>
>> --
>> Motoi Washida
>>
>
> --
> Motoi Washida
> <_mac_applications> <_open> <_defaults>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Completion functions for Mac OS X
  2005-01-15 16:59   ` Completion functions for Mac OS X lists
@ 2005-01-16 16:08     ` Motoi Washida
  2005-01-18  2:10       ` lists
  0 siblings, 1 reply; 3+ messages in thread
From: Motoi Washida @ 2005-01-16 16:08 UTC (permalink / raw)
  To: zsh-users; +Cc: lists

Hi Ryan,

On 2005/01/16, at 1:59, lists wrote:

> defaults read /Applications/TextEdit.app/Contents/Info
>
> will normally display the contents of 
> /Applications/TextEdit.app/Contents/Info.plist
Heh. I didn't know that. Is this a hidden feature? I can't find any 
documents about that.

> If I use the _defaults completion, this doesn't work (and neither does 
> TAB completion: 'defaults read /App<TAB>').  Could _defaults be 
> modified to allow for viewing of xml files which aren't registered as 
> a defaults domain?  I'd love to help but haven't been able to get the 
> hang of writing completions yet.
Here is a patch to complete plist files.

--
Motoi Washida

Index: Completion/Darwin/Command/_defaults
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Darwin/Command/_defaults,v
retrieving revision 1.1
diff -d -u -r1.1 _defaults
--- Completion/Darwin/Command/_defaults	23 Jul 2004 13:38:12 -0000	1.1
+++ Completion/Darwin/Command/_defaults	16 Jan 2005 15:43:35 -0000
@@ -1,12 +1,16 @@
  #compdef defaults

  _defaults_domains(){
-  local str="$(_call_program domains defaults domains 2>/dev/null)"
-  local expl
-  local -a list
-  list=( ${(s/, /)str} -g -globalDomain )
-  _wanted domains expl 'defaults database domain' \
-      compadd -M 'r:|.=* r:|=*' -a list
+  if [[ "`eval echo $PREFIX`" != [/~]* ]]; then
+    local str="$(_call_program domains defaults domains 2>/dev/null)"
+    local expl
+    local -a list
+    list=( ${(s/, /)str} -g -globalDomain )
+    _wanted domains expl 'defaults database domain' \
+        compadd -M 'r:|.=* r:|=*' -a list
+  else
+    _files -g '*.plist(e:"reply=\${REPLY%.plist}":)'
+  fi
  }

  _defaults_keys(){


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Completion functions for Mac OS X
  2005-01-16 16:08     ` Motoi Washida
@ 2005-01-18  2:10       ` lists
  0 siblings, 0 replies; 3+ messages in thread
From: lists @ 2005-01-18  2:10 UTC (permalink / raw)
  To: zsh-users; +Cc: Motoi Washida

Hi Motoi,
	Thanks so much for the quick fix!  I wanted to test on a few different 
systems before replying.

On Jan 16, 2005, at 10:08 AM, Motoi Washida wrote:
>
>
>> defaults read /Applications/TextEdit.app/Contents/Info
>>
>> will normally display the contents of 
>> /Applications/TextEdit.app/Contents/Info.plist
> Heh. I didn't know that. Is this a hidden feature? I can't find any 
> documents about that.

Hmm, I'm not sure where I got the idea of using defaults(1) to read xml 
files.  I don't know if this is openly documented anywhere.

> Here is a patch to complete plist files.

It seems to work great on OS 10.3.7 with zsh 4.2.3.  It doesn't work on 
the same machine with zsh 4.1.1 (which comes with OS 10.3), but that's 
probably ok since one wouldn't get the Darwin completions unless they 
installed zsh 4.2.3 anyway.  How does one get this patch submitted?  
Through PWS?

Thanks,
Ryan

>
> --
> Motoi Washida
>
> Index: Completion/Darwin/Command/_defaults
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/Darwin/Command/_defaults,v
> retrieving revision 1.1
> diff -d -u -r1.1 _defaults
> --- Completion/Darwin/Command/_defaults	23 Jul 2004 13:38:12 -0000	1.1
> +++ Completion/Darwin/Command/_defaults	16 Jan 2005 15:43:35 -0000
> @@ -1,12 +1,16 @@
>  #compdef defaults
>
>  _defaults_domains(){
> -  local str="$(_call_program domains defaults domains 2>/dev/null)"
> -  local expl
> -  local -a list
> -  list=( ${(s/, /)str} -g -globalDomain )
> -  _wanted domains expl 'defaults database domain' \
> -      compadd -M 'r:|.=* r:|=*' -a list
> +  if [[ "`eval echo $PREFIX`" != [/~]* ]]; then
> +    local str="$(_call_program domains defaults domains 2>/dev/null)"
> +    local expl
> +    local -a list
> +    list=( ${(s/, /)str} -g -globalDomain )
> +    _wanted domains expl 'defaults database domain' \
> +        compadd -M 'r:|.=* r:|=*' -a list
> +  else
> +    _files -g '*.plist(e:"reply=\${REPLY%.plist}":)'
> +  fi
>  }
>
>  _defaults_keys(){
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-18  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ED23CF10-DBCD-11D8-BFB6-000D93502E64@h8.dion.ne.jp>
     [not found] ` <5F375244-DBDD-11D8-8A54-000D93502E64@h8.dion.ne.jp>
2005-01-15 16:59   ` Completion functions for Mac OS X lists
2005-01-16 16:08     ` Motoi Washida
2005-01-18  2:10       ` lists

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).