Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Interactive search on the command line?



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?



Messages sorted by: Reverse Date, Date, Thread, Author