file-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFile Search
文件搜索
Modern file and content search.
现代化的文件与内容搜索。
fd - Find Files
fd - 查找文件
bash
undefinedbash
undefinedFind by name
按名称查找
fd config # Files containing "config"
fd -e py # Python files
fd config # 名称包含"config"的文件
fd -e py # Python文件
By type
按类型查找
fd -t f config # Files only
fd -t d src # Directories only
fd -t f config # 仅查找文件
fd -t d src # 仅查找目录
Exclude
排除指定内容
fd -E node_modules # Exclude directory
fd -E "*.min.js" # Exclude pattern
fd -E node_modules # 排除node_modules目录
fd -E "*.min.js" # 排除匹配该模式的文件
Execute command
执行命令
fd -e py -x wc -l # Line count per file
undefinedfd -e py -x wc -l # 统计每个文件的行数
undefinedrg - Search Content
rg - 内容搜索
bash
undefinedbash
undefinedSimple search
简单搜索
rg "TODO" # Find TODO
rg -i "error" # Case-insensitive
rg "TODO" # 查找包含TODO的内容
rg -i "error" # 不区分大小写搜索error
By file type
按文件类型搜索
rg -t py "import" # Python files only
rg -t js -t ts "async" # JS and TS
rg -t py "import" # 仅在Python文件中搜索import
rg -t js -t ts "async" # 在JS和TS文件中搜索async
Context
显示上下文
rg -C 3 "function" # 3 lines before/after
rg -C 3 "function" # 显示匹配内容前后3行
Output modes
输出模式
rg -l "TODO" # File names only
rg -c "TODO" # Count per file
undefinedrg -l "TODO" # 仅输出包含匹配内容的文件名
rg -c "TODO" # 按文件统计匹配次数
undefinedfzf - Interactive Selection
fzf - 交互式选择
bash
undefinedbash
undefinedFind and select
查找并选择
fd | fzf
fd | fzf
With preview
带预览功能
fd | fzf --preview 'bat --color=always {}'
fd | fzf --preview 'bat --color=always {}'
Multi-select
多选模式
fd -e ts | fzf -m | xargs code
undefinedfd -e ts | fzf -m | xargs code
undefinedCombined Patterns
组合用法
bash
undefinedbash
undefinedFind files, search content
查找文件后搜索内容
fd -e py -x rg "async def" {}
fd -e py -x rg "async def" {}
Search, select, open
搜索、选择并打开文件
rg -l "pattern" | fzf --preview 'rg -C 3 "pattern" {}' | xargs vim
undefinedrg -l "pattern" | fzf --preview 'rg -C 3 "pattern" {}' | xargs vim
undefinedQuick Reference
快速参考
| Task | Command |
|---|---|
| Find TS files | |
| Find in src | |
| Search pattern | |
| Search in type | |
| Files with match | |
| Count matches | |
| Interactive | |
| With preview | |
| 任务 | 命令 |
|---|---|
| 查找TS文件 | |
| 在src目录中查找TS文件 | |
| 搜索指定模式 | |
| 按类型搜索 | |
| 查看包含匹配内容的文件 | |
| 统计匹配次数 | |
| 交互式选择 | |
| 带预览的交互式选择 | |
Performance Tips
性能优化技巧
| Tip | Why |
|---|---|
Both respect | Auto-skip node_modules, dist |
Use | Type flags are faster |
| Narrow the path | |
Use | Avoids regex overhead |
| 技巧 | 原因 |
|---|---|
均支持 | 自动跳过node_modules、dist等目录 |
使用 | 类型标记的执行速度更快 |
| 缩小搜索路径 | |
对字面量使用 | 避免正则表达式的性能开销 |
Additional Resources
额外资源
For detailed patterns, load:
- - Git integration, shell functions, power workflows
./references/advanced-workflows.md
如需了解详细用法,请查看:
- - Git集成、Shell函数、高级工作流
./references/advanced-workflows.md