6

How an I list all of the styles defined in a zsh session using the zstyle command? I would like to know this so I know what configuration options are available to me.

1 Answer 1

7

zstyle -L lists all the styles that have been defined, with their values. For a slightly nicer display with only the patterns, you can use

zstyle-list-patterns () {
  local tmp
  zstyle -g tmp
  print -rl -- "${(@o)tmp}"
}

This is a far cry from your goal of listing all the styles that you can configure. For one thing, styles can be based on wildcards, which can be instantiated in infinitely many ways (for example, completion settings can be set per command).

There is no declaration of styles: a function that can be configured through a style calls the zstyle command to look up some value, possibly with variable arguments. It's impossible to anticipate what arguments are going to be passed to zstyle in the future. All you can do is consult the documentation of the function (when it exists) or its source code.

3
  • 1
    Thanks for your answer. I guess it is really unfortunate that I have to consult the documentation/src of a function to determine how it uses styles. Jul 22, 2012 at 22:54
  • I would guess that since autocompletion works for the zstyle command, that you could at least query that somehow: zstyle ':[Hit Tab] Dec 9, 2021 at 7:23
  • 1
    @MattAlexander Good point, that's another method, which is mostly based on hard-coded lists for each field (and some dynamic generation for a few parts). So that'll give you a subset of what can be configured for the functions shipped with zsh. Dec 9, 2021 at 10:00

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.