zsh-users
 help / color / mirror / code / Atom feed
* Expanding a global alias
@ 2007-09-16 18:47 zzapper
  2007-09-16 19:14 ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: zzapper @ 2007-09-16 18:47 UTC (permalink / raw)
  To: zsh-users

Hi

I use a global alias as follows
>alias -g NF='*(.om[1])' # newest file

so I can write say

>cp NF /tmp

Is there any way of making the above (or similar) tab expandable

ie
>cp NF<tab> 

expands to

>cp thanks.php 


-- 
zzapper
http://www.rayninfo.co.uk/vimtips.html


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

* Re: Expanding a global alias
  2007-09-16 18:47 Expanding a global alias zzapper
@ 2007-09-16 19:14 ` Mikael Magnusson
  2007-09-17 16:38   ` Peter Stephenson
  2007-09-20 14:13   ` zzapper
  0 siblings, 2 replies; 6+ messages in thread
From: Mikael Magnusson @ 2007-09-16 19:14 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

On 16/09/2007, zzapper <david@tvis.co.uk> wrote:
> Hi
>
> I use a global alias as follows
> >alias -g NF='*(.om[1])' # newest file
>
> so I can write say
>
> >cp NF /tmp
>
> Is there any way of making the above (or similar) tab expandable
>
> ie
> >cp NF<tab>
>
> expands to
>
> >cp thanks.php

If you press ^Xa it should expand to the *(.om[1]) which you can then
tab expand. (that's ctrl-x a, not ctrl-x ctrl-a, if that happens to
not be a default binding it's _expand_alias).

BTW it seems _expand_alias has a bug...
I have alias -g XP='"`bs file`"' but it expands to only `bs file`, not
"`bs file`".

-- 
Mikael Magnusson


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

* Re: Expanding a global alias
  2007-09-16 19:14 ` Mikael Magnusson
@ 2007-09-17 16:38   ` Peter Stephenson
  2007-09-20 14:13   ` zzapper
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2007-09-17 16:38 UTC (permalink / raw)
  To: zsh-users

On Sun, 16 Sep 2007 21:14:47 +0200
"Mikael Magnusson" <mikachu@gmail.com> wrote:
> BTW it seems _expand_alias has a bug...
> I have alias -g XP='"`bs file`"' but it expands to only `bs file`, not
> "`bs file`".

That seems to have been deliberate, but I presume it was an oversight.

Index: Completion/Base/Completer/_expand_alias
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand_alias,v
retrieving revision 1.2
diff -u -r1.2 _expand_alias
--- Completion/Base/Completer/_expand_alias	29 May 2001 11:59:51 -0000	1.2
+++ Completion/Base/Completer/_expand_alias	17 Sep 2007 16:36:05 -0000
@@ -39,7 +39,10 @@
 [[ -z $tmp && $sel = *G* ]] && tmp=$dis_galiases[$word]
 
 if [[ -n $tmp ]]; then
-  $pre _wanted aliases expl alias compadd -UQ ${(Q)tmp%%[[:blank:]]##}
+  # We used to remove the quoting from the value in the parameter.
+  # That was probably just an oversight: an alias is always replaced
+  # literally.
+  $pre _wanted aliases expl alias compadd -UQ ${tmp%%[[:blank:]]##}
 elif (( $#pre )) && zstyle -t ":completion:${curcontext}:" complete; then
   $pre _aliases -s "$sel" -S ''
 else

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


.


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

* Re: Expanding a global alias
  2007-09-16 19:14 ` Mikael Magnusson
  2007-09-17 16:38   ` Peter Stephenson
@ 2007-09-20 14:13   ` zzapper
  2007-09-20 14:57     ` Peter Stephenson
  2007-09-20 15:09     ` Bart Schaefer
  1 sibling, 2 replies; 6+ messages in thread
From: zzapper @ 2007-09-20 14:13 UTC (permalink / raw)
  To: zsh-users

"Mikael Magnusson" <mikachu@gmail.com> wrote in 
news:237967ef0709161214j43bae920j297feb782a5ee678@mail.gmail.com:

> If you press ^Xa it should expand to the *(.om[1]) which you can then
> tab expand. (that's ctrl-x a, not ctrl-x ctrl-a, if that happens to
> not be a default binding it's _expand_alias).

A lot of these control commands eg ^Xa are inoperative for me.

Is that because:
a) I need to enable them?
b) I have vi compatible line editing set
c) I'm on cygwin
d) It was O.J.Simpson




-- 
zzapper
http://www.rayninfo.co.uk/vimtips.html


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

* Re: Expanding a global alias
  2007-09-20 14:13   ` zzapper
@ 2007-09-20 14:57     ` Peter Stephenson
  2007-09-20 15:09     ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2007-09-20 14:57 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

zzapper wrote:
> "Mikael Magnusson" <mikachu@gmail.com> wrote in 
> news:237967ef0709161214j43bae920j297feb782a5ee678@mail.gmail.com:
> > If you press ^Xa it should expand to the *(.om[1]) which you can then
> > tab expand. (that's ctrl-x a, not ctrl-x ctrl-a, if that happens to
> > not be a default binding it's _expand_alias).
> 
> A lot of these control commands eg ^Xa are inoperative for me.
> 
> Is that because:
> a) I need to enable them?
> b) I have vi compatible line editing set
> c) I'm on cygwin
> d) It was O.J.Simpson

A combination of a), b) and d).  You've turned on vi mode and the way
you currently have things initialised you would need to add them by
hand; but if you hadn't been so busy worrying about O.J. Simpson, you
might have noticed that if you set vi mode before running compinit the
bindings will be there.  In other words,

bindkey -v
autoload -U compinit
compinit

ought to make keys of that sort work.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


.


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

* Re: Expanding a global alias
  2007-09-20 14:13   ` zzapper
  2007-09-20 14:57     ` Peter Stephenson
@ 2007-09-20 15:09     ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2007-09-20 15:09 UTC (permalink / raw)
  To: zsh-users

On Sep 20,  2:13pm, zzapper wrote:
} Subject: Re: Expanding a global alias
}
} A lot of these control commands eg ^Xa are inoperative for me.
} 
} Is that because:
} a) I need to enable them?
} b) I have vi compatible line editing set
} c) I'm on cygwin
} d) It was O.J.Simpson

It's (b), though (d) was a good guess.


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

end of thread, other threads:[~2007-09-20 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-16 18:47 Expanding a global alias zzapper
2007-09-16 19:14 ` Mikael Magnusson
2007-09-17 16:38   ` Peter Stephenson
2007-09-20 14:13   ` zzapper
2007-09-20 14:57     ` Peter Stephenson
2007-09-20 15:09     ` Bart Schaefer

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).