viewing-files
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesebat: Enhanced File Viewer with Syntax Highlighting
bat:具备语法高亮的增强型文件查看器
Always invoke bat skill for enhanced file viewing - do not execute bash commands directly.
Use bat as a modern replacement for cat with beautiful syntax highlighting, Git integration, and smart features.
请始终调用bat技能进行增强型文件查看——不要直接执行bash命令。
将bat作为cat的现代替代工具,它拥有美观的语法高亮、Git集成和智能特性。
When to Use bat vs cat
bat与cat的使用场景对比
Use bat when:
- Viewing source code or structured text files
- Syntax highlighting improves readability
- Need Git integration or line numbers
- Working with files >50 lines where highlighting helps
- Previewing changes from other tools
Use cat when:
- Very small files (<10 lines)
- Non-text/binary files
- Simple concatenation without formatting
- When highlighting would add noise
- Performance-critical operations on many tiny files
Common workflow: Any skill → bat skill (preview enhanced output)
使用bat的场景:
- 查看源代码或结构化文本文件
- 语法高亮可提升可读性时
- 需要Git集成或行号显示时
- 处理超过50行、高亮有助于阅读的文件时
- 预览其他工具的输出变更时
使用cat的场景:
- 极小的文件(少于10行)
- 非文本/二进制文件
- 无需格式的简单拼接操作
- 高亮会造成干扰时
- 对大量微小文件进行性能敏感的操作时
常见工作流:任意技能 → bat技能(预览增强型输出)
Default Strategy
默认策略
Invoke bat skill for enhanced file viewing with syntax highlighting. Use when viewing source files, documentation, or when syntax highlighting improves readability.
Common workflow: Any discovery skill → bat skill (preview enhanced output).
调用bat技能进行带语法高亮的增强型文件查看。在查看源文件、文档或语法高亮能提升可读性时使用。
常见工作流:任意发现类技能 → bat技能(预览增强型输出)。
Key Options
核心选项
Display Control
显示控制
- line numbers only
-n/--number - plain output (no decorations)
-p/--plain - show non-printable characters
-A/--show-all - view specific lines
--line-range START:END - disable line wrapping
--wrap never - set tab width to N spaces
--tabs N
- 仅显示行号
-n/--number - 纯文本输出(无装饰)
-p/--plain - 显示不可打印字符
-A/--show-all - 查看指定行范围
--line-range START:END - 禁用自动换行
--wrap never - 将制表符宽度设置为N个空格
--tabs N
Language & Themes
语言与主题
- force language detection
-l/--language LANG - show supported languages
--list-languages - show available themes
--list-themes - set color theme (default: Monokai Extended)
--theme NAME - auto-switch themes based on terminal
--theme-dark/--theme-light - environment variable for default theme
BAT_THEME
- 强制指定语言检测
-l/--language LANG - 显示支持的语言列表
--list-languages - 显示可用主题
--list-themes - 设置配色主题(默认:Monokai Extended)
--theme NAME - 根据终端自动切换主题
--theme-dark/--theme-light - 用于设置默认主题的环境变量
BAT_THEME
Output Styling
输出样式
- control output (numbers,changes,header,grid,snip)
--style COMPONENTS - control decorations
--decorations auto|never|always - control coloring
--color always|never|auto
- 控制输出元素(行号、变更、标题、网格、代码片段)
--style COMPONENTS - 控制装饰元素的显示
--decorations auto|never|always - 控制颜色显示
--color always|never|auto
Paging
分页
- control paging behavior
--paging auto|never|always - set custom pager
--pager COMMAND - environment variable
BAT_PAGER
- 控制分页行为
--paging auto|never|always - 设置自定义分页工具
--pager COMMAND - 分页工具的环境变量
BAT_PAGER
When to Use
适用场景
- Code Review: View source files with syntax highlighting and line numbers
- Git Workflow: Check file modifications and view historical versions
- Documentation: Colorize help pages and documentation
- File Concatenation: Replace cat with enhanced features
- Integration: Use as previewer for fzf or other tools
- 代码评审:通过语法高亮和行号查看源文件
- Git工作流:检查文件修改并查看历史版本
- 文档查看:为帮助页面和文档添加颜色高亮
- 文件拼接:用增强特性替代cat工具
- 工具集成:作为fzf或其他工具的预览器
Core Principles
核心原则
- Enhanced cat: Drop-in replacement with intelligent improvements
- Smart Defaults: Automatic paging when appropriate, Git integration when in repo
- Syntax Highlighting: Supports 200+ languages with accurate detection
- Performance Optimized: Fast loading, efficient rendering, handles large files well
- 增强版cat:可直接替代cat的智能改进工具
- 智能默认值:在合适时自动分页,在Git仓库中自动启用Git集成
- 语法高亮:支持200+种语言,检测准确
- 性能优化:加载速度快,渲染高效,可轻松处理大文件
Detailed Reference
详细参考
For comprehensive usage patterns, integration examples, advanced features, and troubleshooting, load bat guide when needing:
- Git integration workflows
- Output styling and customization details
- Theme configuration and options
- Performance optimization tips
- Shell integration examples
The guide includes:
- Core usage patterns and language control
- Git integration workflows
- Output styling and customization
- Integration with other tools (fzf, git, ripgrep)
- Advanced features and configuration
- Performance tips and troubleshooting
如需全面的使用模式、集成示例、高级特性和故障排除指南,请加载bat指南,适用于以下场景:
- Git集成工作流
- 输出样式与自定义细节
- 主题配置与选项
- 性能优化技巧
- Shell集成示例
该指南包含:
- 核心使用模式与语言控制
- Git集成工作流
- 输出样式与自定义
- 与其他工具的集成(fzf、git、ripgrep)
- 高级特性与配置
- 性能技巧与故障排除
Skill Combinations
技能组合
For Discovery Phase
发现阶段
- fd → fzf → bat: Find files, select interactively, view with syntax highlighting
- ripgrep → fzf → bat: Search content, select matches, view with highlighting
- jq/yq → fzf → bat: Extract data, select entries, view formatted output
- fd → fzf → bat:查找文件、交互式选择、带语法高亮查看
- ripgrep → fzf → bat:搜索内容、选择匹配项、带高亮查看
- jq/yq → fzf → bat:提取数据、选择条目、查看格式化输出
For Analysis Phase
分析阶段
- analyzing-code-structure → bat: Preview structural changes with syntax highlighting
- sd → bat: Preview find-and-replace results before committing
- extracting-code-structure → bat: View extracted code structure with formatting
- analyzing-code-structure → bat:带语法高亮预览结构变更
- sd → bat:提交前预览查找替换结果
- extracting-code-structure → bat:带格式查看提取的代码结构
For Output Preview
输出预览
- tokei → bat: View code statistics with formatted output
- ripgrep → bat: Preview matched files with context highlighting
- jq/yq → bat: View extracted structured data with syntax formatting
- tokei → bat:查看带格式的代码统计信息
- ripgrep → bat:带上下文高亮预览匹配文件
- jq/yq → bat:带格式查看提取的结构化数据
Integration Examples
集成示例
bash
undefinedbash
undefinedInteractive file viewer
交互式文件查看器
fd --type file | fzf --preview="bat --color=always --style=numbers {}" --bind="enter:execute(bat {})"
fd --type file | fzf --preview="bat --color=always --style=numbers {}" --bind="enter:execute(bat {})"
undefined