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行就是新增長的行