zsh-users
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Axel Beckert <abe@deuxchevaux.org>,
	"zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: refering to 2nd from last history parameter?
Date: Thu, 22 Jan 2015 18:52:01 +0300	[thread overview]
Message-ID: <3006201421941921@web23g.yandex.ru> (raw)
In-Reply-To: <20150122134016.GV26664@sym.noone.org>



22.01.2015, 16:42, "Axel Beckert" <abe@deuxchevaux.org>:
> Hi,
>
> On Thu, Jan 22, 2015 at 12:18:19PM +0000, zzapper wrote:
>>  I don't think it's possible
>>
>>  ls !$    last parameter of previous command
>>
>>  echo a b c d e f g h
>>
>>  I don't think I can grab 'g' without counting left to right
>
> Interesting question.
>
> I would have expected that using negativ numbers would work (with
> CSH_JUNKIE_HISTORY enabled of course):
>
>   % echo !:-2
>
> But this actually seems an abbreviation for
>
>   % echo !:0-2
>
> despite this is not documented in the man page. (I may come up with a
> documentation patch for that later.)

It is documented:“x-y    A range of words; x *defaults to 0*.”

>
> It though seems consistent with tcsh which behaves the same way.
>
> Despite I never thought about it so far, I'd use such a feature if I
> knew it exists. Would come in handy with many rsync/scp/cp/etc.
> command-lines to reuse the source argument if there were a bunch of
> dashed options before it.
>
> I wonder what would be a good syntax for such a feature as "-n"
> seems already taken. Maybe something "<n" as in e.g.
>
>   % echo !:<2
>
> (And would we count from 0 or from 1, i.e. would "!:<0" or "!:<1" be a
> synonym for "!:$"? :-)

I would say that `!:<1` resulting in a second word counted from the end is rather unexpected.

>
>                 Kind regards, Axel
> --
> /~\  Plain Text Ribbon Campaign                   | Axel Beckert
> \ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
>  X   See http://www.nonhtmlmail.org/campaign.html | abe@noone.org (Mail+Jabber)
> / \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)


  reply	other threads:[~2015-01-22 15:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-22 12:18 zzapper
2015-01-22 12:57 ` Peter Stephenson
2015-01-22 13:34   ` zzapper
2015-01-23 19:59   ` Wayne Davison
2015-01-26 12:05   ` zzapper
2015-01-26 12:16     ` Peter Stephenson
2015-01-26 13:17       ` Axel Beckert
2015-01-26 14:32         ` Peter Stephenson
2015-01-26 21:30           ` Axel Beckert
2015-01-22 13:40 ` Axel Beckert
2015-01-22 15:52   ` ZyX [this message]
2015-01-22 16:09     ` Axel Beckert
2015-01-22 17:17 ` Bart Schaefer
2015-01-22 17:51   ` zzapper

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=3006201421941921@web23g.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=abe@deuxchevaux.org \
    --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).