environment-variables – 如何查看默认的zsh设置(HISTSIZE,SAVEHIST,…)

前端之家收集整理的这篇文章主要介绍了environment-variables – 如何查看默认的zsh设置(HISTSIZE,SAVEHIST,…)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何查看所有zsh设置的当前值?

例如,我目前没有设置HISTSIZE和SAVEHIST,所以env | grep HIST并设置| grep HIST什么都没显示.那么我怎样才能看到正在使用的默认值?

解决方法

除解析文档或源代码外,没有选项可以获取未定义变量的默认值.

HISTSIZE和SAVEHIST不是设置,它们是特殊变量.有一种方法可以列出所有变量,但我知道无法列出那些特殊的变量并用作设置.

为了帮助您列出作为变量实现的参数,有zsh /参数模块(zmodload zsh /参数加载它).它有一个关联数组$parameters,其中键是变量名,值是变量类型描述. HISTSIZE和SAVEHIST都显示为整数特殊. HISTCHARS在那里以标量特殊形式出现.请注意,RANDOM在这里只显示为HISTSIZE:integer-special,因此您不能使用它来获取用作选项的特殊变量.但是你可以随时使用man zshparam的SHELL部分使用的PARAMETERS.

我不知道任何允许您确定这些参数的默认值的选项,除了解析文档或源代码.

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

如果要查看非默认设置:

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.

使用它也是有意义的:

# 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.

或者只需按照帮助和使用即可

# 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

请注意,使用kshoptionprint选项时,setopt和unsetopt的输出匹配.

猜你在找的Linux相关文章