zsh-users
 help / color / mirror / code / Atom feed
From: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>
To: "Zefram" <zefram@fysh.org>, <mkkwong@lucent.com>
Cc: <zsh-users@sunsite.auc.dk>
Subject: RE: some directory changing tools to share
Date: Tue, 7 Mar 2000 10:36:37 +0300	[thread overview]
Message-ID: <000201bf8807$df037e80$21c9ca95@mow.siemens.ru> (raw)
In-Reply-To: <E12S7vP-0001Dv-00@crucigera.fysh.org>

Just to add some more sugar and correct some mistakes :-)

>
>
> mkkwong@lucent.com wrote:
> >non-directory filenames that also begins with "Le" (you can get
> around one
> >of the problems by redefining the completion rules for "cd").
>
> Actually most of what your "c" function does can be done with completion
> in zsh.  The standard completion for cd only completes to names of
> directories anyway.  With
>
> 	zstyle ':completion:*:cd:*' matcher-list 'm:{A-Z}={a-z}'

This won't work for two reasons.

1. to allow lower case on _command_line_ to match upper case in _file_names_
(in our case) matcher is exactly other way round

2. the 'matcher-list' is gobal and cannot be set on per-command basis. The
above will be ignored by Zsh. If you want it to apply to just cd - use
"matcher" style (you even can specify, that only local directories and not
directories in CDPATH should be treated this way).

So, the correct way is

zstyle ':completion:*:cd:*' matcher 'm:{a-z}={A-Z}'

Oh, yes, and this will work for any directory in your CDPATH - not just for
subdirectory of your current dir.

>
> completion on cd is one-way case insensitive, the way you want it.
> With menu completion, you can have the lexically first match inserted
> straight away (or with AUTO_MENU on the second or third tab), so you don't
> even have to type an unambiguous prefix.  Continuing menu completion,
> you can get to matches other than the lexically first, still without
> typing an unambiguous prefix.  And the big advantage of completion over
> your functions is that if you make a mistake, you can see it before
> actually executing the command.
>

And you can turn on visual full screen selection so that you can select
match from the list using customary Up/Down/Left/Right key binding (cursor
keys). This may save you some TABs if list is long.

> >Using my tool, you just type
> >
> >   c l
>
> With MENU_COMPLETE and the zstyle noted above, "cd l<tab>".  If you use
> AUTO_CD, you can actually drop the "cd " part.
>
> >Rule 1 works recursively down the directory tree one level at a
> time, with
> >unlimited depth.
>
> Same for completion.  It'll add a trailing "/" to any complete match
> it inserts, after which you can press tab again to complete the next
> level down.  If in the middle of menu completion, and you don't want
> to type any actual letters, type the "/" yourself to break out of menu
> completion and then tab will start completion at the next level.
>

And if you use menu selection mentioned above, you can press "/" and this
will try to complete next level immediately.

> >   c p t g
> >
> >takes you all the way to Perl/Test/Gui.
>
> "cd p<tab>t<tab>g<tab>".
>

Actually, with current completion and the above matcher this is even
simpler:

cd p/t/g<TAB>

If the Perl/Test/Gui is unambiguous, it will be immediately expanded. If you
happen to have

Perl/Test/Gui and
Perl/Trash/Gum

Zsh will expand the longest prefix. What happens then, is configurable - I
personally set it to start menu selection, so I get something like

cd Perl/T<CURSOR here>/G
Test Trash

and can select Test, press "/" and immediately start completing inside of
Perl/Test. Or enter "e" (note - cursor is exactly at the right place) and
hit TAB once more - and it will expand the whole input. And, as mentioned by
Zefram, you have full control and see exactly what thye result is. And can
always cancel command you you made a mistake.

Hey, is not this cool! :))

-andrej

Have a nice DOS!
B >>



  reply	other threads:[~2000-03-07  7:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-06 21:14 mkkwong
2000-03-07  0:32 ` Zefram
2000-03-07  7:36   ` Andrej Borsenkow [this message]
2000-03-07 15:33   ` mkkwong
2000-03-07 11:06 ` Oliver Kiddle
2000-03-07 17:46   ` Bart Schaefer

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='000201bf8807$df037e80$21c9ca95@mow.siemens.ru' \
    --to=andrej.borsenkow@mow.siemens.ru \
    --cc=mkkwong@lucent.com \
    --cc=zefram@fysh.org \
    --cc=zsh-users@sunsite.auc.dk \
    /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).