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

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

概述如何查看所有zsh设置的当前值? 例如,我目前没有设置HISTSIZE和SAVEHIST,所以env | grep HIST并设置| grep HIST什么都没显示.那么我怎样才能看到正在使用的默认值? 除解析文档或源代码外,没有选项可以获取未定义变量的默认值. 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 histnobanghistextendedhistoryhistfcntllockhistignorealldupshistignorespacehistnostorehistreduceblankshistsavenodupshistverifyincappendhistory

如果要查看非默认设置:

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 histnoappendhistorycshjunkIEhistoryhistallowclobbernohistbeephistexpiredupsfirsthistfindnodupshistignoredupshistlexwordshistnofunctionsnohistsavebycopyhistsubstpatternsharehistory

If no arguments are supplIEd,the names of all options currently unset are printed.

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

# setopt kshoptionprint# setopt | grep histnoappendhistory       offnobanghist            oncshjunkIEhistory      offextendedhistory       onhistallowclobber      offnohistbeep            offhistexpiredupsfirst   offhistfcntllock         onhistfindnodups        offhistignorealldups     onhistignoredups        offhistignorespace       onhistlexwords          offhistnofunctions       offhistnostore           onhistreduceblanks      onnohistsavebycopy      offhistsavenodups        onhistsubstpattern      offhistverify            onincappendhistory      onsharehistory          off

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

总结

以上是内存溢出为你收集整理的environment-variables – 如何查看默认的zsh设置(HISTSIZE,SAVEHIST,…)全部内容,希望文章能够帮你解决environment-variables – 如何查看默认的zsh设置(HISTSIZE,SAVEHIST,…)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1047394.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存