添加默认fzf ctrl-r 查找并执行history
This commit is contained in:
parent
e66dc3cd3f
commit
7fbce52dde
|
|
@ -105,6 +105,10 @@ _OMZ_APPLY_CHPWD_HOOK
|
|||
行为:
|
||||
1. 载入时,会自动切换到上一次cd过的目录
|
||||
2. 发生cd命令时,自动记录当前cd的目录(在缓存文件中)
|
||||
|
||||
_OMZ_APPLY_HISTORYBYFZF
|
||||
是否允许fzf管理ctrl_r快捷键
|
||||
默认true
|
||||
```
|
||||
|
||||
## PLUGINS
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export RUNEWIDTH_EASTASIAN=0
|
||||
export FZF_DEFAULT_OPTS="--height 12 --scrollbar=▌▐ --info=inline-right --margin=1 --layout=reverse --history=$OMZ/cache/fzfhistory"
|
||||
export FZF_DEFAULT_OPTS="--height 12 --scrollbar=▌▐ --info=inline-right --layout=reverse --history=$OMZ/cache/fzfhistory"
|
||||
export FZF_DEFAULT_COMMAND="fd --exclude={.git,.idea,.vscode,.sass-cache,node_modules,build,dist,vendor} --type f"
|
||||
export FZF_PREVIEW_COMMAND='bash $OMZ/lib/file_preview.sh {}'
|
||||
|
||||
|
|
@ -22,3 +22,17 @@ zstyle ':fzf-tab:complete:git-show:*' fzf-preview 'git show --color=always $word
|
|||
zstyle ':fzf-tab:complete:git-checkout:*' fzf-preview '[ -f "$realpath" ] && git diff --color=always $word || git log --color=always $word'
|
||||
zstyle ':fzf-tab:complete:*:*' fzf-preview 'bash $OMZ/lib/file_preview.sh ${(Q)realpath}'
|
||||
zstyle ':fzf-tab:complete:*:*' fzf-flags --height=12
|
||||
|
||||
_apply_historybyfzf() {
|
||||
function historybyfzf (){
|
||||
if [ $#LBUFFER -gt 0 ]; then
|
||||
BUFFER=$(history -n | awk '!seen [$0]++' | fzf --query $LBUFFER)
|
||||
else
|
||||
BUFFER=$(history -n | awk '!seen [$0]++' | fzf)
|
||||
fi
|
||||
CURSOR=$#BUFFER
|
||||
zle redisplay
|
||||
}
|
||||
zle -N historybyfzf
|
||||
bindkey '^r' historybyfzf
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,3 @@ _apply_chpwd_hook() {
|
|||
currentdir=$(cat $OMZ/cache/currentdir 2>/dev/null)
|
||||
[ -d "$currentdir" ] && cd $currentdir
|
||||
}
|
||||
|
||||
[ "$_OMZ_APPLY_PREEXEC_HOOK" = "true" ] && _apply_preexec_hook
|
||||
[ "$_OMZ_APPLY_CHPWD_HOOK" = "true" ] && _apply_chpwd_hook
|
||||
|
|
|
|||
5
omz.zsh
5
omz.zsh
|
|
@ -4,3 +4,8 @@ source $OMZ/config/git.zsh
|
|||
source $OMZ/config/fzf.zsh
|
||||
source $OMZ/config/hook.zsh
|
||||
source $OMZ/themes/simple.zsh-theme
|
||||
|
||||
# configuration
|
||||
[ "$_OMZ_APPLY_PREEXEC_HOOK" = "true" ] && _apply_preexec_hook # file: $OMZ/config/hook.zsh
|
||||
[ "$_OMZ_APPLY_CHPWD_HOOK" = "true" ] && _apply_chpwd_hook # file: $OMZ/config/hook.zsh
|
||||
[ "$_OMZ_APPLY_HISTORYBYFZF" = "false" ] || _apply_historybyfzf # file: $OMZ/config/fzf.zsh
|
||||
|
|
|
|||
Loading…
Reference in New Issue