From d7d5df4f6c7dd380e49b47e4da840226a828968a Mon Sep 17 00:00:00 2001 From: Fabian Dellwing Date: Wed, 23 Sep 2020 09:38:28 +0200 Subject: [PATCH] add plugin and readme --- README.md | 23 ++++++++++++++++++++++- zsh-bat.plugin.zsh | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 zsh-bat.plugin.zsh diff --git a/README.md b/README.md index df66bb3..ac4fcfe 100644 --- a/README.md +++ b/README.md @@ -1 +1,22 @@ -# zsh-bat \ No newline at end of file +# zsh-bat + +[oh-my-zsh plugin](https://github.com/robbyrussell/oh-my-zsh) for easy integration with [bat](https://github.com/sharkdp/bat). + +## Prerequisites + +You should have `bat` installed, this plugin will do nothing otherwise. + +## Install + +Create a new directory in `$ZSH_CUSTOM/plugins` called `zsh-bat` and clone this repo into that directory. +``` +git clone https://github.com/fdellwing/zsh-bat.git $ZSH_CUSTOM/plugins/zsh-bat +``` + +Add `zsh-bat` to your plugin list in `~/.zshrc`. + +## Usage + +This plugin will replace `cat` with `bat`. To run the real `cat` command, you can use `rcat`. It will also enable syntax highlighting for the `man` command. + +For usage help with `bat`, see [sharkdp/bat](https://github.com/sharkdp/bat). diff --git a/zsh-bat.plugin.zsh b/zsh-bat.plugin.zsh new file mode 100644 index 0000000..6e867c4 --- /dev/null +++ b/zsh-bat.plugin.zsh @@ -0,0 +1,6 @@ + +if command -v bat >/dev/null 2>&1; then + alias rcat=$(which cat) + alias cat=$(which bat) + export MANPAGER="sh -c 'col -bx | bat -l man -p'" +fi