我最爱的fzf工具有什么独特之处?
- 内容介绍
- 文章标签
- 相关推荐
本文共计592个文字,预计阅读时间需要3分钟。

fzf搜索神器;fzf是一个交互式的搜索工具,它从标准输入读取一个选项列表,并将选中的项写入标准输出。无论你在哪里使用搜索或从多个选项中选择,都应该考虑使用fzf。
模糊搜索神器fzf;
fzf是一个交互式的搜索工具,他从标准输入读取一个候选列表,并将选择项写入标准输出。
你在任何地方用到搜索或者从多个候选项中选择一个时,都应该想到fzf,用fzf增强原来的搜索选择,让你爽的飞起!
安装git clone --depth 1 github.com/junegunn/fzf.git ~/.fzf ~/.fzf/install 几个小样例
交互式搜索文件
find * -type f | fzf > selected
搜索文件并使用vim打开
vim $(fzf)
灵魂-简洁的搜索语法
Token Match type Description
sbtrkt
fuzzy-match
Items that matchsbtrkt
'wild
exact-match (quoted)
Items that includewild
^music
prefix-exact-match
Items that start withmusic
.mp3$
suffix-exact-match
Items that end with.mp3
!fire
inverse-exact-match
Items that do not includefire
!^music
inverse-prefix-exact-match
Items that do not start withmusic
!.mp3$
inverse-suffix-exact-match
Items that do not end with.mp3
命令行按键绑定和增强
快捷键
描述
ctrl+t
搜索当前目录下的文件或者目录并打印到命令行中
ctrl+r
将原来的历史命令搜索增强
alt+c
选择目录并切换到选择的目录
模糊补全
# Files under the current directory # - You can select multiple items with TAB key vim **<TAB> # Files under parent directory vim ../**<TAB> # Files under parent directory that match `fzf` vim ../fzf**<TAB> # Files under your home directory vim ~/**<TAB> # Directories under current directory (single-selection) cd **<TAB> # Directories under ~/github that match `fzf` cd ~/github/fzf**<TAB>
还有我不常用的,进程号搜索,环境变量设置,host搜索
搜索并预览文件内容然后在.zshrc里用函数或别名
alias tt='fzf --preview '"'"'[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --| rougify {} || highlight -O ansi -l {} || coderay {} || cat {}) 2> /dev/null | head -500'"'" git命令增强
切换git分支
alias gcof='git checkout ${$(git branch --remote | fzf)#"origin/"}'
merge指定分支内容
alias gmf='git merge ${$(git branch --remote | fzf)#"origin/"}' 参考
官方git:github.com/junegunn/fzf
segmentfault.com/a/1190000011328080
www.jianshu.com/p/b48131e4ad06
本文共计592个文字,预计阅读时间需要3分钟。

fzf搜索神器;fzf是一个交互式的搜索工具,它从标准输入读取一个选项列表,并将选中的项写入标准输出。无论你在哪里使用搜索或从多个选项中选择,都应该考虑使用fzf。
模糊搜索神器fzf;
fzf是一个交互式的搜索工具,他从标准输入读取一个候选列表,并将选择项写入标准输出。
你在任何地方用到搜索或者从多个候选项中选择一个时,都应该想到fzf,用fzf增强原来的搜索选择,让你爽的飞起!
安装git clone --depth 1 github.com/junegunn/fzf.git ~/.fzf ~/.fzf/install 几个小样例
交互式搜索文件
find * -type f | fzf > selected
搜索文件并使用vim打开
vim $(fzf)
灵魂-简洁的搜索语法
Token Match type Description
sbtrkt
fuzzy-match
Items that matchsbtrkt
'wild
exact-match (quoted)
Items that includewild
^music
prefix-exact-match
Items that start withmusic
.mp3$
suffix-exact-match
Items that end with.mp3
!fire
inverse-exact-match
Items that do not includefire
!^music
inverse-prefix-exact-match
Items that do not start withmusic
!.mp3$
inverse-suffix-exact-match
Items that do not end with.mp3
命令行按键绑定和增强
快捷键
描述
ctrl+t
搜索当前目录下的文件或者目录并打印到命令行中
ctrl+r
将原来的历史命令搜索增强
alt+c
选择目录并切换到选择的目录
模糊补全
# Files under the current directory # - You can select multiple items with TAB key vim **<TAB> # Files under parent directory vim ../**<TAB> # Files under parent directory that match `fzf` vim ../fzf**<TAB> # Files under your home directory vim ~/**<TAB> # Directories under current directory (single-selection) cd **<TAB> # Directories under ~/github that match `fzf` cd ~/github/fzf**<TAB>
还有我不常用的,进程号搜索,环境变量设置,host搜索
搜索并预览文件内容然后在.zshrc里用函数或别名
alias tt='fzf --preview '"'"'[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --| rougify {} || highlight -O ansi -l {} || coderay {} || cat {}) 2> /dev/null | head -500'"'" git命令增强
切换git分支
alias gcof='git checkout ${$(git branch --remote | fzf)#"origin/"}'
merge指定分支内容
alias gmf='git merge ${$(git branch --remote | fzf)#"origin/"}' 参考
官方git:github.com/junegunn/fzf
segmentfault.com/a/1190000011328080
www.jianshu.com/p/b48131e4ad06

