* Alias for a dynamic variable?
@ 2006-04-27 16:04 zzapper
2006-04-27 16:10 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: zzapper @ 2006-04-27 16:04 UTC (permalink / raw)
To: zsh-users
Hi
How can I have a (Global) alias for a dynamic variable such as $OLDPWD
hope this isn't a DOH!
--
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias for a dynamic variable?
2006-04-27 16:04 Alias for a dynamic variable? zzapper
@ 2006-04-27 16:10 ` Peter Stephenson
2006-04-27 16:34 ` zzapper
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2006-04-27 16:10 UTC (permalink / raw)
To: zsh-users
zzapper wrote:
> Hi
> How can I have a (Global) alias for a dynamic variable such as $OLDPWD
Not sure I understand the question, but you can have a global alias by
having a global alias... here's one with $SECONDS...
% alias -g s='$SECONDS'
% echo s
184291.9458320000
% echo s
184293.7045900000
% echo s
184294.6965270000
(I have "typeset -F SECONDS" in my .zshrc.)
--
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
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias for a dynamic variable?
2006-04-27 16:10 ` Peter Stephenson
@ 2006-04-27 16:34 ` zzapper
2006-04-27 16:45 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: zzapper @ 2006-04-27 16:34 UTC (permalink / raw)
To: zsh-users
Peter Stephenson <pws@csr.com> wrote in news:EXCHANGE03cWo7Z0xK40000be27
@exchange03.csr.com:
> alias -g s='$OLDPWD'
this works such that I can
>cd s
but I cant do
>cp s/somefile .
So decided what I really want is just a shorter name for $OLDPWD
so I can do say
> cp $OP/somefile .
In fact tab completion helps so I don't have to type all of $OLDPWD
--
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias for a dynamic variable?
2006-04-27 16:34 ` zzapper
@ 2006-04-27 16:45 ` Peter Stephenson
2006-04-27 17:00 ` zzapper
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2006-04-27 16:45 UTC (permalink / raw)
To: zsh-users
zzapper wrote:
> Peter Stephenson <pws@csr.com> wrote in news:EXCHANGE03cWo7Z0xK40000be27
> @exchange03.csr.com:
>
> > alias -g s='$OLDPWD'
> this works such that I can
> >cd s
> but I cant do
> >cp s/somefile .
You can already use ~- to refer to the relevant directory.
If you want a parameter, you can assign it every time the directory
changes:
chpwd() { O=$OLDPWD }
--
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
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias for a dynamic variable?
2006-04-27 16:45 ` Peter Stephenson
@ 2006-04-27 17:00 ` zzapper
0 siblings, 0 replies; 5+ messages in thread
From: zzapper @ 2006-04-27 17:00 UTC (permalink / raw)
To: zsh-users
Peter Stephenson <pws@csr.com> wrote in news:EXCHANGE03iF5DIz5pF0000bf83
@exchange03.csr.com:
> zzapper wrote:
>> Peter Stephenson <pws@csr.com> wrote in
news:EXCHANGE03cWo7Z0xK40000be27
>> @exchange03.csr.com:
>>
>> > alias -g s='$OLDPWD'
>> this works such that I can
>> >cd s
>> but I cant do
>> >cp s/somefile .
>
> You can already use ~- to refer to the relevant directory.
>
cp ~-/suk.jpg .
Thanx JWTDO
Dead obvious when you know how!
zzapper
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-04-27 17:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-27 16:04 Alias for a dynamic variable? zzapper
2006-04-27 16:10 ` Peter Stephenson
2006-04-27 16:34 ` zzapper
2006-04-27 16:45 ` Peter Stephenson
2006-04-27 17:00 ` zzapper
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).