2012-08-11 18 views

回答

7

沒有選項來獲得一個未定義的變量的默認值,除了解析文檔或源代碼。

HISTSIZESAVEHIST都沒有設置,他們是特殊的變量。有一種方法可以列出所有變量,但我知道沒有辦法列出那些特殊的並用作設置的方法。

爲幫助您列出作爲變量實現的參數,有zsh/parameter模塊(zmodload zsh/parameter加載它)。它有一個關聯數組$parameters,其中鍵是變量名,值是變量類型描述。 HISTSIZESAVEHIST均以integer-special的形式出現。 HISTCHARS作爲scalar-special出現在那裏。不過,請注意RANDOM出現在這裏只是作爲HISTSIZEinteger-special,所以你不能用它來獲取作爲選項的特殊變量。但您始終可以使用man zshparamPARAMETERS USED BY THE SHELL部分。

我不知道任何選項,讓你確定這些參數的默認值,除了解析文檔或源代碼。

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

如果你想看到非默認設置:

如果沒有提供參數,目前的所有選項的名字被打印出來。選擇表單是爲了儘量減少與當前仿真的默認選項的差異(默認 仿真爲本地zsh,如zshoptions(1)中所示)。默認情況下爲仿真啓用的選項僅在前綴爲no時才顯示,而其他選項則顯示前綴no且僅在打開時才顯示爲 。除了用戶從默認狀態更改的選項以外,shell自動激活的任何選項(例如,SHIN_STDIN或INTERACTIVE)將在列表中顯示爲 。格式可以通過選項KSH_OPTION_PRINT進一步修改,但是在這種情況下,選擇帶或不帶no前綴的選項的基本原理保持不變。

這也是情理之中的使用:

# unsetopt | grep hist 
noappendhistory 
cshjunkiehistory 
histallowclobber 
nohistbeep 
histexpiredupsfirst 
histfindnodups 
histignoredups 
histlexwords 
histnofunctions 
nohistsavebycopy 
histsubstpattern 
sharehistory 

如果沒有提供參數,目前沒有設置所有的選項的名稱被打印出來。

或者追蹤的幫助和使用

# 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選項使用setoptunsetopt匹配輸出。

+0

感謝嘗試@ZyX,但是這隻能說明布爾設置。它不顯示HISTSIZE和SAVEHIST,它們是整數設置。 – 2012-08-30 16:39:52

+0

@RobBednark他們不是設置。它們是特殊的變量。有一種方法可以列出* all *變量,但我不知道只列出那些特殊的並用作設置的方法。 – ZyX 2012-08-30 17:13:56

+0

還有一些特殊變量(在C模塊中定義的變量)不能完全列出(它們出現在'set'輸出中,但沒有值)。 – ZyX 2012-08-30 17:52:09

0

我不知道你左右...(我的意思是,i do use .prezto),但是這是在 「自動完成」 我得到在進入setoptTAB ......

enter image description here

這是告訴我像有用的東西..

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

and

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

4

要顯示當前值,你是否已設定與否(在這種情況下,它顯示了默認值):

➜ ~ echo $SAVEHIST 
10000 
➜ ~ echo $HISTSIZE 
10000