zshのextend_historyは何をしますか?

zshのextend_historyは何をしますか?

Extended_historyオプションを見て、次のように使用するのを見ました。zshの各ディレクトリの履歴しかし、実際にextend_historyが何をしているのか理解できませんでしたか?

メッセージは何ですか? zsh_historyで使用できます。それ以外の場合、このオプションが設定されていないと使用できません。

~からhttp://zsh.sourceforge.net/Doc/Release/Options.html#Optionsその内容は――

EXTENDED_HISTORY <C>

    Save each command’s beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file. The format of this prefixed data is:

    ‘: <beginning time>:<elapsed seconds>;<command>’. 

しかし、少なくとも履歴コマンドを実行することには何の利点もありません。

 shirish@debian ~ % history | grep tail -5
      601* exit
      602* history
      603* exit
      604  cd
      605  cat ~/.zsh/.zshrc
      606   tail -5 history

このように~/.zsh/.zshrc設定しました -

shirish@debian ~ % cat ~/.zsh/.zshrc
# Lines configured by zsh-newuser-install
HISTFILE=~/.zsh//.histfile
HISTSIZE=1000
SAVEHIST=100000
setopt inc_append_history autocd nomatch notify share_history extended_history
bindkey -e
# End of lines configured by zsh-newuser-install

# display how long all tasks over 10 seconds take
export REPORTTIME=10

# The following lines were added by compinstall
zstyle :compinstall filename '/home/shirish/.zsh//.zshrc'

autoload -Uz compinit promptinit
compinit
promptinit
# End of lines added by compinstall

prompt adam1

オプションを設定したり、オプションを削除した後は何の違いもなく、意味がありません。

shirish@debian ~ % cat ~/.zsh/.zshrc | grep setopt
setopt inc_append_history autocd nomatch notify share_history extended_history
shirish@debian ~ % source ~/.zsh/.zshrc           
shirish@debian ~ % history -E                     
  337  11.1.2018 23:33  history | grep apg
  338  11.1.2018 23:33  man apg
  339  11.1.2018 23:33  cd
  340  11.1.2018 23:33  apg -a 1 -M n -n 3 -m 20
  341  11.1.2018 23:33  apg -a 1 -M SNCL -n 3 -m 20
  342  11.1.2018 23:33  history 
  343  11.1.2018 23:33  history -E
  344  11.1.2018 23:33  leafpad ~/.zsh/.zshrc
  345  11.1.2018 23:33  cat ~/.zsh/.zshrc
  346  11.1.2018 23:33  source ~/.zsh/.zshrc
  347  11.1.2018 23:33  history -E
  348  11.1.2018 23:33  exit
  349  11.1.2018 23:33  history -E
  350  11.1.2018 23:34  leafpad ~/.zsh/.zshrc
  351  11.1.2018 23:35  cat ~/.zsh/.zshrc | grep setopt
  352  11.1.2018 23:35  source ~/.zsh/.zshrc
shirish@debian ~ % leafpad ~/.zsh/.zshrc          
shirish@debian ~ % source ~/.zsh/.zshrc 
shirish@debian ~ % history -E           
  340  11.1.2018 23:33  apg -a 1 -M n -n 3 -m 20
  341  11.1.2018 23:33  apg -a 1 -M SNCL -n 3 -m 20
  342  11.1.2018 23:33  history 
  343  11.1.2018 23:33  history -E
  344  11.1.2018 23:33  leafpad ~/.zsh/.zshrc
  345  11.1.2018 23:33  cat ~/.zsh/.zshrc
  346  11.1.2018 23:33  source ~/.zsh/.zshrc
  347  11.1.2018 23:33  history -E
  348  11.1.2018 23:33  exit
  349  11.1.2018 23:33  history -E
  350  11.1.2018 23:34  leafpad ~/.zsh/.zshrc
  351  11.1.2018 23:35  cat ~/.zsh/.zshrc | grep setopt
  352  11.1.2018 23:35  source ~/.zsh/.zshrc
  353  11.1.2018 23:35  history -E
  354  11.1.2018 23:36  leafpad ~/.zsh/.zshrc
  355  11.1.2018 23:36  source ~/.zsh/.zshrc
shirish@debian ~ % cat ~/.zsh/.zshrc | grep setopt
setopt inc_append_history autocd nomatch notify share_history

ご覧のとおり、特に違いはないようです。

% zsh --version
zsh 5.4.2 (x86_64-debian-linux-gnu)

ベストアンサー1

オプションに関係なく、出力はhistory -E常に同じですEXTENDED_HISTORY。コマンド期間は履歴ファイルに直接保存されます(値を表示するにはファイルを確認してください)。

ただし、もう1つの問題は、この動作をオーバーライドするオプションがあることです。sleep 3次の項目を生成する同様のコマンドを実行して、これが機能しているかどうかをテストできます。

pol@host ~ $ sleep 3
pol@host ~ $ tail -1 ${HISTFILE}
: 1530663493:3;sleep 3
pol@host ~ $ setopt | grep hist
extendedhistory
histignoredups
incappendhistorytime

「Duration」の値が3であることがわかります。 3以外の場合、EXTENDED_HISTORY操作を妨げる別のオプションセットがある可能性があります。これにはとSHARED_HISTORYが含まれますINC_APPEND_HISTORY。前者が必要な場合は幸運ではありません。後者の場合、上記で説明したように値をINC_APPEND_HISTORY_TIME持ちたい場合は別の選択肢があります。EXTENDED_HISTORY

おすすめ記事