返回顶部
b

bat-cat蝙蝠猫

A cat clone with syntax highlighting, line numbers, and Git integration - a modern replacement for cat.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
3,019
下载量
免费
免费
2
收藏
概述
安装方式
版本历史

bat-cat

bat - 更好的 cat

cat 的增强版,支持语法高亮、行号和 Git 集成。

快速开始

基本用法

bash

查看文件并显示语法高亮

bat README.md

查看多个文件

bat file1.js file2.py

显示行号(默认)

bat script.sh

不显示行号

bat -p script.sh

查看模式

bash

纯文本模式(类似 cat)

bat -p file.txt

显示不可打印字符

bat -A file.txt

压缩空白行

bat -s file.txt

分页显示(大文件自动启用)

bat --paging=always file.txt bat --paging=never file.txt

语法高亮

语言检测

bash

根据扩展名自动检测

bat script.py

强制指定语言

bat -l javascript config.txt

显示所有支持的语言

bat --list-languages

主题

bash

列出可用主题

bat --list-themes

使用特定主题

bat --theme=Monokai Extended file.py

在配置文件中设置默认主题

~/.config/bat/config: --theme=Dracula

行范围

bash

显示指定行


bat -r 10:20 file.txt

从某行到末尾

bat -r 100: file.txt

从开头到指定行

bat -r :50 file.txt

多个范围

bat -r 1:10 -r 50:60 file.txt

Git 集成

bash

显示 Git 修改(新增/删除/修改的行)


bat --diff file.txt

显示装饰信息(Git + 文件头)

bat --decorations=always file.txt

输出控制

bash

原始输出(无样式)


bat --style=plain file.txt

自定义样式

bat --style=numbers,changes file.txt

可用样式:auto, full, plain, changes, header, grid, numbers, snip

bat --style=header,grid,numbers file.txt

常见用例

快速文件预览:
bash
bat file.json

查看带语法高亮的日志:
bash
bat error.log

可视化比较文件:
bash
bat --diff file1.txt
bat file2.txt

编辑前预览:
bash
bat config.yaml && vim config.yaml

管道中的 cat 替代:
bash
bat -p file.txt | grep pattern

查看特定函数:
bash
bat -r 45:67 script.py # 如果函数在第45-67行

与其他工具集成

作为 man 手册的分页器:
bash
export MANPAGER=sh -c col -bx | bat -l man -p
man grep

与 ripgrep 配合:
bash
rg pattern -l | xargs bat

与 fzf 配合:
bash
fzf --preview bat --color=always --style=numbers {}

与 diff 配合:
bash
diff -u file1 file2 | bat -l diff

配置

创建 ~/.config/bat/config 文件设置默认值:

设置主题

--theme=Dracula

显示行号、Git 修改和文件头,但不显示网格

--style=numbers,changes,header

在终端中使用斜体文本

--italic-text=always

添加自定义映射

--map-syntax *.conf:INI

性能建议

  • - 管道输出时使用 -p 纯文本模式
  • 程序化使用输出时使用 --paging=never
  • bat 会缓存已解析的文件以加快后续访问速度

小贴士

  • - 别名: alias cat=bat -p 可直接替代 cat
  • 分页器: 使用 export PAGER=bat 作为分页器
  • 在 Debian/Ubuntu 上: 命令可能是 batcat 而非 bat
  • 自定义语法: 添加到 ~/.config/bat/syntaxes/
  • 性能: 对于大文件,使用 bat --paging=never 或直接使用 cat

常用标志

  • - -p / --plain:纯文本模式(无行号/装饰)
  • -n / --number:仅显示行号
  • -A / --show-all:显示不可打印字符
  • -l / --language:设置语法高亮的语言
  • -r / --line-range:仅显示指定行范围

文档

GitHub:https://github.com/sharkdp/bat
手册页:man bat
自定义:https://github.com/sharkdp/bat#customization

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 bat-cat-1776378869 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 bat-cat-1776378869 技能

通过命令行安装

skillhub install bat-cat-1776378869

下载

⬇ 下载 bat-cat v1.0.0(免费)

文件大小: 2.22 KB | 发布时间: 2026-4-17 14:43

v1.0.0 最新 2026-4-17 14:43
bat-cat 1.0.0 – Initial Release

- Introduces a modern cat replacement with syntax highlighting, line numbers, and Git integration.
- Provides quick start usage instructions and examples for common scenarios.
- Documents advanced features: viewing modes, syntax highlighting options, themes, and output styles.
- Explains integration with tools like ripgrep, fzf, diff, and use as a pager.
- Includes configuration tips, performance advice, and common command flags.
- References official resources for further documentation and customization.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部