zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: "expanding" to copy-earlier-word
Date: Thu, 13 Aug 2015 12:45:55 +0100	[thread overview]
Message-ID: <20150813114555.GA29873@linux.vnet.ibm.com> (raw)
In-Reply-To: <20150813112422.52f8cc84@pwslap01u.europe.root.pri>

On Thu, Aug 13, 2015 at 11:24:22AM +0100, Peter Stephenson wrote:
> On Thu, 13 Aug 2015 10:57:27 +0100
> Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > I've bound ctrl-j to copy-earlier-word, so I can copy the last word
> > of the previously executed command line to the current command
> > line.  Is there a way to do the same as part of the expansion
> > process?
> 
> Hisotry expansion allows you to select previous words, but you'll need
> to count from the left when retrieving words from the current line: you
> can use ":$" to indicate the last argument, which with !# is the
> previous argument, but "-" indicates a range, not a negative offset.
> There was some discussion about this anomaly a couple of months ago;
> it's potentially fixable with some new syntax (I've forgotten if there
> was a conclusion).
> 
> > What I'd like to have this something like this:
> > 
> >   $ make foo
> >   $ ./<copy-earlier-word>
> 
> ./!:$

Sort of works for me after "setopt histexpand".  Unfortunately, is
saves "./foo" in the history instead of "./!:$".  It looks like
there's no option to have the unexpanded string stored in the
history?

According to the man page history expansion comes first, followed
by alias expansion, the result of which is not stored in the
history files, so I guess the sequence is

 1) history expansion,
 2) save command line in history,
 3) alias expansion,
 4) everything else.

If there was a way to change that order to

 1) save command line in history,
 2) alias expansion,
 3) history expansion,
 4) everything else.

one could even have history expansion in aliases:

  $ alias -g PW='!:$'
  $ make foo
  $ echo PW

(I guess the global alias wouldn't allow "echo ./PW" anyway).

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


  reply	other threads:[~2015-08-13 11:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13  9:57 Dominik Vogt
2015-08-13  9:59 ` Dominik Vogt
2015-08-13 10:24 ` Peter Stephenson
2015-08-13 11:45   ` Dominik Vogt [this message]
2015-08-13 12:16     ` Peter Stephenson
2015-08-13 16:22       ` Bart Schaefer
2015-08-13 16:48         ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150813114555.GA29873@linux.vnet.ibm.com \
    --to=vogt@linux.vnet.ibm.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).