How to view default zsh settings (HISTSIZE, SAVEHIST, ...)

How to view current values โ€‹โ€‹for all zsh settings?

for example, I currently do not have HISTSIZE and SAVEHIST, so env | grep HIST env | grep HIST and set | grep HIST set | grep HIST show nothing. So how can I find out which default values โ€‹โ€‹are used?

+7
source share
3 answers

There is no way to get the default value for an undefined variable, except for processing documentation or source code.

HISTSIZE and SAVEHIST are not settings; they are special variables. There is a way to list all the variables, but I do not know how to list those that are special and are used as settings.

To help you list parameters implemented as variables, there is a zsh/parameter module ( zmodload zsh/parameter to load it). It has an associative array of $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 a scalar-special . Note that RANDOM appears here as HISTSIZE : integer-special , so you cannot use this to get special variables used as parameters. But you can always use the PARAMETERS USED BY THE SHELL man zshparam .

I do not know a single parameter that will allow you to define default values โ€‹โ€‹for these parameters, except for parsing documentation or source code.

 # setopt | grep hist nobanghist extendedhistory histfcntllock histignorealldups histignorespace histnostore histreduceblanks histsavenodups histverify incappendhistory 

If you want to see settings other than the default settings:

If no arguments are specified, the names of all currently set parameters will be printed. The form is selected in such a way as to minimize the default differences for the current emulation (by default, the emulation is native zsh, shown as in zshoptions (1)). The parameters that are enabled by default for emulation are displayed with a prefix not only if they are turned off, while other parameters are displayed without a prefix, and only if they are turned on. In addition to the parameters changed by the user by default, any parameters automatically activated by the shell (for example, SHIN_STDIN or INTERACTIVE) will be displayed in the list. The format is additionally modified by the KSH_OPTION_PRINT option, however, the rationale for choosing parameters with a prefix with or without it remains unchanged 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 specified, the names of all disabled options will be printed.

Or just follow the tips 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 same as the kshoptionprint parameter.

+7
source

To display the current value, regardless of whether you set it or not (in this case, it shows the default value):

 โžœ ~ echo $SAVEHIST 10000 โžœ ~ echo $HISTSIZE 10000 
+4
source

I donโ€™t know about VAC ... (I mean I use .prezto ), but this is "autocomplete" I go into setopt TAB ...

enter image description here

which tells me useful things like ..

-- zsh options (set) -- noaliases noautoresume nohashdirs nohistverify nonomatch ...

and

-- zsh options (unset) -- allexport cshjunkiehistory hashexecutablesonly kshglob nullglob singlecommand ...

0
source

All Articles