bat的目的很是简单,就是一个带有语法高亮的cat,他们的选项基本都同样,另外它还会自动获取你git的信息,可以标出目前文件和git缓存区文件的区别,这样你一眼就能够看出你的修改。git
先安装RUST, 而后github
# Recursive clone to retrieve all submodules git clone --recursive https://github.com/sharkdp/bat # Build (debug version) cd bat cargo build --release # copy bat to your $PATH cp target/release/bat /home/harriszh/app/bin
显示单文件: bat README.md
显示多文件: bat src/*.rs
从标准输入读取,显式描述语言: yaml2json .travis.yml | json_pp | bat -l json
shell
和cat
类似:json
bat > note.md # 快速建立文件 bat header.md content.md footer.md > document.md bat -n main.rs # 显示行数, 默认行为 bat f - g # 依次显示文件f, stdin, 文件g
#bat export BAT_THEME=GitHub export BAT_CONFIG_DIR="$(bat cache --config-dir)" # use the following command to parse new syntaxed files into a binary cache #bat cache --init # use the following command to go back the default setting #bat cache --clear
能够用bat --list-themes
来获得目前可用的主题
能够用bat --theme=TwoDark
来定义此次使用的主题
能够用bat --style=numbers,changes
来定义输出缓存
BAT_CONFIG_DIR="$(bat cache --config-dir)" mkdir -p "$BAT_CONFIG_DIR/themes" cd "$BAT_CONFIG_DIR/themes" # Download a theme in '.tmTheme' format, for example: git clone https://github.com/greggb/sublime-snazzy # Update the binary cache bat cache --init
bat使用的是syntest这个语法库,syntest使用的是sublime的语法格式app
BAT_CONFIG_DIR="$(bat cache --config-dir)" mkdir -p "$BAT_CONFIG_DIR/syntaxes" cd "$BAT_CONFIG_DIR/syntaxes" # Put new '.sublime-syntax' language definition files # in this folder (or its subdirectories), for example: git clone https://github.com/tellnobody1/sublime-purescript-syntax bat cache --init
能够从这里来下载ui
实际要下的是这两个文件
没有办法直接下载,因此打开文件,而后复制粘贴下来
放到~/.config/bat/syntaxes里, 而后更新bat的语法库this
bat cache --init
能够用bat --list-languages
来确认spa
效果以下:firefox
bat会查看当前文件和git缓存里文件的修改,效果以下如上图69,70行就是新增长的行