跳到主要内容

bash历史搜索


# 启用历史搜索功能
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

# 改善历史记录设置
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTCONTROL=ignoredups:erasedups
export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"

# 实时保存历史记录
shopt -s histappend
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

# 启用部分匹配
shopt -s histverify