_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?
Yes, your interpretation is correct (from skimming your long question).
Parameter expansion flags apply to parameter expansions. When you want it applied to any arbitrary string instead, you need to either store that string in a variable as in:
var=%1N
filename=${(%)var}
Or (as a hack) you can use the ${var:-string}
parameter expansion and leave the var
part empty: ${(%):-%1N}
. That's a common trick(see 1
2
3
4
5
6
7
8
9
10
11
12
13 here for instance), though that makes for pretty illegible code. Alternatively, you could use the ${param+string}
syntax and use a parameter like $-
or $0
or $#
that is always set (${(%)-+%1N}
). That's neither shorter nor more legible though.
Here, you can also use print -P %1N
Best Answer
${1-$PWD}
is a shell parameter expansion pattern.It is used to expand to a default value based on another -- whatever on the right of
-
. Here, in your case:If
$1
is unset, then the expansion of$PWD
would be substitutedOtherwise i.e. if
$1
is set to any value (including null), its value would be used as the result of expansionExample: