_kadmin
is probably a completer function for the kadmin
tool - not a directory. If you attempt completion on something that zsh
can't find as a command, a directory or a valid and known command argument completion, it then starts to offer completion functions as possible expansion candidates. By default, zsh
comes with a lot of completers, many of which you may not need - there are bundles for AIX, BSD, Cygwin, various Linux distributions, etc, and they all get read and installed into the shell. If you attempt an expansion on something zsh
can't find, it has all those installed completion functions to offer you instead.
You configure zsh
not to offer completer functions by putting this in your ~/.zshrc
:
zstyle ':completion:*:functions' ignored-patterns '_*'
Reload the file and you should no longer be offered completion functions for tools you don't have installed. Have a look at the zshcompsys
manpage for (a lot) more detail.
EDIT in reply to UPDATE 3
If _kadmin
is actually a user account, you can configure zsh
to not offer it in completions. It seems the approach is to list the user accounts you do want the shell to consider, which limits any names offered only to those listed. The zstyle
line is something like this:
zstyle ':completion:*' users asgeo1 root
I think you can list as many users as you like after the users
tag. The shell will then only offer those users' home directories as possible completions for the cd
function or builtin.
I don't know why adding the username to the ignored-patterns in the completion.zsh
file didn't work - did you reload your config after making the change?
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
Best Answer
From http://zshwiki.org/home/examples/compsys/ignore#ignore_parent_directory
See also
info zsh ignore-parents
for details. Reproduced below for zsh 5.4.2: