所有 zsh 历史记录

所有 zsh 历史记录

我正在将 zsh 与 Prezto 一起使用,我的问题是为什么我只能看到有限数量的历史记录:

~ >>> history2651  git checkout -- modules/prompt/functions/prompt_sorin_setup
 2652  git diff runcoms/zshrc
 2653  git diff
 2654  cd ~
 2655  cd Work/TEST
 2656  git status
 2657  rm test.m
 2658  git checkout -- apps/TravelApp/TravelApp/Views/Form/AXFormDateCell.xib
 2659  zsh --version
 2660  om ~/.zshrc&
 2663  ls -la

这是我的 zshrc 设置,我将历史大小设置为较大的数字

# Increase history file size
export HISTSIZE=1000000000
export SAVEHIST=$HISTSIZE
setopt EXTENDED_HISTORY

# from http://zanshin.net/2013/02/02/zsh-configuration-from-the-ground-up/
# ===== Basics
setopt no_beep # don't beep on error
setopt interactive_comments # Allow comments even in interactive shells (especially for Muness)

# ===== Changing Directories
setopt auto_cd # If you type foo, and it isn't a command, and it is a directory in your cdpath, go there
setopt cdablevarS # if argument to cd is the name of a parameter whose value is a valid directory, it will become the current directory
setopt pushd_ignore_dups # don't push multiple copies of the same directory onto the directory stack

# ===== Expansion and Globbing
setopt extended_glob # treat #, ~, and ^ as part of patterns for filename generation

# ===== History
setopt append_history # Allow multiple terminal sessions to all append to one zsh command history
setopt extended_history # save timestamp of command and duration
setopt inc_append_history # Add comamnds as they are typed, don't wait until shell exit
setopt hist_expire_dups_first # when trimming history, lose oldest duplicates first
setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events
setopt hist_ignore_space # remove command line from history list when first character on the line is a space
setopt hist_find_no_dups # When searching history don't display results already cycled through twice
setopt hist_reduce_blanks # Remove extra blanks from each command line being added to history
setopt hist_verify # don't execute, just expand history
setopt share_history # imports new commands and appends typed commands to history

# ===== Completion
setopt always_to_end # When completing from the middle of a word, move the cursor to the end of the word
setopt auto_menu # show completion menu on successive tab press. needs unsetop menu_complete to work
setopt auto_name_dirs # any parameter that is set to the absolute name of a directory immediately becomes a name for that directory
setopt complete_in_word # Allow completion from within a word/phrase

unsetopt menu_complete # do not autoselect the first completion entry

答案1

历史
相当于
函数库
这又相当于
FC-L-16-1

人zshbuiltins

因此,如果您想要查看更大的范围,请将其提供给命令。例如:

历史-1000

答案2

这并不是您想要的,我总是建议为此历史搜索功能添加别名,以便更轻松地浏览。

alias s='search'
search() {
   history -i | grep "$1"
}

输出的结果类似如下:

 2992  2020-11-13 15:56  terraform init
 3000  2020-11-13 16:03  cd .terraform.d
 3016  2020-11-13 16:24  mkdir terraform-modules

答案3

所有 zsh 历史记录

history 0

你可以使用类似别名

alias history='history 0'

相关内容