How do I see the current values for all the zsh settings?
e.g., I don't currently have HISTSIZE and SAVEHIST set, so env | grep HIST
and set | grep HIST
show nothing. So then how can I see what default values are being used?
There is no option to get the default value for an undefined variable except parsing documentation or source code.
HISTSIZE
and SAVEHIST
are not settings, they are special variables. There is a way to list all variables, but I know of no way to list those that are special and are used as settings.
To help you list parameters implemented as variables, there is the zsh/parameter
module (zmodload zsh/parameter
to load it). It has an associative array $parameters
where keys are variable names and values are variable type descriptions. Both HISTSIZE
and SAVEHIST
appear there as integer-special
. HISTCHARS
appears there as scalar-special
. Note though that RANDOM
appears here just as HISTSIZE
: integer-special
, so you can’t use this to get special variables used as options. But you can always use the PARAMETERS USED BY THE SHELL
section of man zshparam
.
I don't know of any option that will allow you to determine default values of those parameters, except parsing documentation or source code.
# setopt | grep hist
nobanghist
extendedhistory
histfcntllock
histignorealldups
histignorespace
histnostore
histreduceblanks
histsavenodups
histverify
incappendhistory
If you want to see non-default settings:
If no arguments are supplied, the names of all options currently set are printed. The form is chosen so as to minimize the differences from the default options for the current emulation (the default emulation being native zsh, shown as in zshoptions(1)). Options that are on by default for the emulation are shown with the prefix no only if they are off, while other options are shown without the prefix no and only if they are on. In addition to options changed from the default state by the user, any options activated automatically by the shell (for example, SHIN_STDIN or INTERACTIVE) will be shown in the list. The format is further modified by the option KSH_OPTION_PRINT, however the rationale for choosing options with or without the no prefix remains the same in this case.
It also makes sense to use:
# unsetopt | grep hist
noappendhistory
cshjunkiehistory
histallowclobber
nohistbeep
histexpiredupsfirst
histfindnodups
histignoredups
histlexwords
histnofunctions
nohistsavebycopy
histsubstpattern
sharehistory
If no arguments are supplied, the names of all options currently unset are printed.
Or just follow the help and use
# setopt kshoptionprint
# setopt | grep hist
noappendhistory off
nobanghist on
cshjunkiehistory off
extendedhistory on
histallowclobber off
nohistbeep off
histexpiredupsfirst off
histfcntllock on
histfindnodups off
histignorealldups on
histignoredups off
histignorespace on
histlexwords off
histnofunctions off
histnostore on
histreduceblanks on
nohistsavebycopy off
histsavenodups on
histsubstpattern off
histverify on
incappendhistory on
sharehistory off
Note that the output of setopt
and unsetopt
match when the kshoptionprint
option is used.
To show the current value, whether you have set it or not (in which case it shows the default value):
➜ ~ echo $SAVEHIST
10000
➜ ~ echo $HISTSIZE
10000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With