zsh-users
 help / color / mirror / code / Atom feed
* directory stack expansion
@ 2007-01-18 22:48 N.J. Thomas
  2007-01-18 23:15 ` Chris Johnson
  0 siblings, 1 reply; 3+ messages in thread
From: N.J. Thomas @ 2007-01-18 22:48 UTC (permalink / raw)
  To: zsh-users

Given the following directory stack:

    $ dirs -v
    0       /etc
    1       /tmp
    3       /home/foo

I often do things like "cd ~+3", "mkdir ~+1/foo", etc.

Often times, I want to be able to expand the directory. The reason for
this is that the directory stack changes often, and "mkdir ~+1/foo"
makes sense when "~+1" has the value of /tmp, but not much sense when it
is /etc or whatever. If I recall a command from the history, "cd ~+3"
might have an entirely different meaning depending on the value of the
stack.

Right now, the only way I can do this is by typing this at the prompt:

    $ cd `echo ~+1`

and then hitting tab after the second backtick. Is there a way to get
Zsh to get to expand without the backticks?

thanks,
Thomas

-- 
N.J. Thomas
njt@ayvali.org
Etiamsi occiderit me, in ipso sperabo


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

* Re: directory stack expansion
  2007-01-18 22:48 directory stack expansion N.J. Thomas
@ 2007-01-18 23:15 ` Chris Johnson
  2007-01-18 23:21   ` N.J. Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Johnson @ 2007-01-18 23:15 UTC (permalink / raw)
  To: N.J. Thomas; +Cc: zsh-users

N.J. Thomas sent me the following 0.8K:

> Right now, the only way I can do this is by typing this at the prompt:
> 
>     $ cd `echo ~+1`
> 
> and then hitting tab after the second backtick. Is there a way to get
> Zsh to get to expand without the backticks?

The zshzle man page lists all the builtin widgets that zsh provides, and
the one that seems to do the trick for me is:

    expand-word (^X*) (unbound) (unbound)
        Attempt shell expansion on the current word.

Control-X followed by * (Shift-8) is bound in the emacs keymap.  That's
not exactly easy to type, but you should be able to map it to something
easier:

   bindkey '^X^D' expand-word

-- 
Chris Johnson
cjohnson@cs.utk.edu
http://www.cs.utk.edu/~cjohnson


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

* Re: directory stack expansion
  2007-01-18 23:15 ` Chris Johnson
@ 2007-01-18 23:21   ` N.J. Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: N.J. Thomas @ 2007-01-18 23:21 UTC (permalink / raw)
  To: Chris Johnson; +Cc: zsh-users

* Chris Johnson <cjohnson@cs.utk.edu> [2007-01-18 18:15:06 -0500]:
> > $ cd `echo ~+1`
> > Is there a way to get Zsh to get to expand without the backticks?
> 
>     expand-word (^X*) (unbound) (unbound)
>         Attempt shell expansion on the current word.

Excellent, that's exactly what I was looking for. Much thanks.

Thomas

-- 
N.J. Thomas
njt@ayvali.org
Etiamsi occiderit me, in ipso sperabo


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

end of thread, other threads:[~2007-01-18 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-18 22:48 directory stack expansion N.J. Thomas
2007-01-18 23:15 ` Chris Johnson
2007-01-18 23:21   ` N.J. Thomas

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