From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24753 invoked by alias); 30 Nov 2015 03:27:28 -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: 21014 Received: (qmail 5485 invoked from network); 30 Nov 2015 03:27:25 -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=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=g6F8SCPE/gl5RQM4rOqvXCxuK18=; b=mCv5Y8 zwUlRloZSYOuaOJFd58S5+AHeYa+zoYUNgwX/puBlkTv6KT4yJd5y9ARp9NI63hB 2c/ETuUECS/UtBgqwlwdVNcoS6yE6pNlGEASXqffClPabcyF24/37xn0HMYDawuO Jq2p8Z6lapVv52+QzOrXtRPf+1VjJXUlxEMhM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=g6F8SCPE/gl5RQM4rOqvXCxuK18=; b=ozF68 68d0aa+G3D5TnqoFqwJasmaFvF1VxVkZbvsRwADcvqjKxGpq802YaPrWLw6+WVAs QHyo0+GzeNBTVkUuh6PGoqM8jPi94SuG/oplvoIXpilphzjevkokJ+j2MAlKPpiJ Ica/R85XIJxtDCsS7H/8uqU59GA/2dgU3qjpKo= X-Sasl-enc: Ah7s5xj0oSjse/zHEXPejAvSoyaEB5bpyqwM2v0lpsMc 1448853557 Date: Mon, 30 Nov 2015 03:19:15 +0000 From: Daniel Shahaf To: Scott Frazer Cc: zsh-users@zsh.org Subject: Re: Interactive search on the command line? Message-ID: <20151130031915.GD2504@tarsus.local2> References: <20151126080400.GA20074@linux.vnet.ibm.com> <565B723B.70900@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <565B723B.70900@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Scott Frazer wrote on Sun, Nov 29, 2015 at 16:46:35 -0500: > On 11/26/15 3:04 AM, Dominik Vogt wrote: > >Is there a way to do an interactive search (or at least a > >non-interactive string search) in the command line editor? I > >often have extremely long gcc command lines where I want to delete > >an option or do some editing in the middle of the command line, > >and moving the cursor to the interesting spot is quite tedious. > > > > I wrote something recently that might help, it lets you jump to > anywhere in the command line with just a couple keystrokes: > > https://github.com/scfrazer/zsh-jump-target Thanks, I'll install that. > I'm pretty new to zsh, so I wrote it like I would have in a different > language. If there is a better way to do things, suggestions are > welcome. I wouldn't know you were new to zsh if you didn't say so; the code looks as good as anyone's. The one thing I would suggest is to use the ${BUFFER[(i)$char]} syntax in the 'for' loop, which should translate to a strchr() or strstr() call at the C level. (There's also the ${(ps:$char:)BUFFER} syntax, but I'm not sure it gains you anything.) Also, three minor points: - With recent zsh, WARN_CREATE_GLOBAL complains: (anon):1: scalar parameter ZSH_JUMP_TARGET_CHOICES created globally in function (anon) (anon):2: scalar parameter ZSH_JUMP_TARGET_STYLE created globally in function (anon) The fix is to declare these parameters either global ('typeset -g') or 'local'. - You could use 'region_highlight+=("foo bar baz")' to append to the array. - You might use an 'always' block to restore $orig_region_highlight. Thanks again! Daniel P.S. Perhaps you could throw a LICENSE file into that repository?