7

I am using zsh with grml's zshrc as a base. As part of my work I access network path regulary (e.g NFS. AFS.)

If I write /a/long/network/path/on/the/other/side/of/the/world press TAB twice it is painfully slow as zsh start searching under /a/ then /a/long /a/long/network etc...

At the same time running ls /a/long/network/path/on/the/other/side/of/the/world returns in a sec. So I would like to tell zsh to stop second guessing me. (If I write /usr/src/linuxx/ and then press tab it figures out that i wanted /usr/src/linux/ and this is cool however because the network it does me more harm than good). I would like to only autocomplete "at the end" after the last slash.

Sometimes I am using a workaround cd into the directory then use autocompletion. Surely there must be a better way.

How can I achieve this?

6

This kind of behavior is configured through styles (except for a few fundamentals that have options). You'll want to turn off path-completion.

By default, filename completion examines all components of a path to see if there are completions of that component. For example, /u/b/z can be completed to /usr/bin/zsh. Explicitly setting this style to false inhibits this behaviour for path components up to the / before the cursor

zstyle ':completion:*' path-completion false

You may want to turn on accept-exact-dirs instead. With path-completion left on and accept-exact-dirs turned on, zsh will only attempt completion for path components other than the last one if the path doesn't exist.

zstyle ':completion:*' accept-exact-dirs true
  • I see that I just accepted this answer. I think I should have also said: "awesome this is exactly what I need" -ed. thx ;-). – ttyS0 Sep 29 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.