警告
本文最后更新于 2023-05-27,文中内容可能已过时。
通过 Ctrl-f
查找并以 vim
打开目标文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
## 在 ~/.zshrc
## fzf : Ctr-f -------------------------------------------------
# .zshrc example
function __fsel_files() {
setopt localoptions pipefail no_aliases 2> /dev/null
eval find ./ -type f -print | fzf -m "$@" | while read item; do
echo -n "${(q)item} "
done
local ret=$?
echo
return $ret
}
function fzf-vim {
selected=$(__fsel_files)
if [[ -z "$selected" ]]; then
zle redisplay
return 0
fi
zle push-line # Clear buffer
BUFFER="vim $selected";
zle accept-line
}
zle -N fzf-vim
bindkey "^f" fzf-vim
|