From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22448 invoked by alias); 13 Aug 2015 11:56:14 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20405 Received: (qmail 5906 invoked from network); 13 Aug 2015 11:56:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Helo: d06dlp02.portsmouth.uk.ibm.com X-MailFrom: vogt@linux.vnet.ibm.com X-RcptTo: zsh-users@zsh.org Date: Thu, 13 Aug 2015 12:45:55 +0100 From: Dominik Vogt To: Zsh Users Subject: Re: "expanding" to copy-earlier-word Message-ID: <20150813114555.GA29873@linux.vnet.ibm.com> Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: Zsh Users References: <20150813095727.GA19151@linux.vnet.ibm.com> <20150813112422.52f8cc84@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150813112422.52f8cc84@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15081311-0041-0000-0000-0000053F18B7 On Thu, Aug 13, 2015 at 11:24:22AM +0100, Peter Stephenson wrote: > On Thu, 13 Aug 2015 10:57:27 +0100 > Dominik Vogt 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 > > $ ./ > > ./!:$ 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