From fb11d31d6d93e3d5ae7e0748e8e13d530482c4e3 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 25 May 2023 13:07:06 +0200 Subject: bash: using bat as a replacement for cat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is only done if the binary actually exists, and then we change environment variables such as MANPAGER and MANROFFOPT so everything works seemlessly. Signed-off-by: Miquel Sabaté Solà --- .bashrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to '.bashrc') diff --git a/.bashrc b/.bashrc index bc95137..e70d4a2 100644 --- a/.bashrc +++ b/.bashrc @@ -42,6 +42,17 @@ alias lisa='ls -lisa --group-directories-first --time-style=+"%d.%m.%Y %H:%M" -- alias ..='cd ..' alias cd..='cd ..' +## +# If `bat` is available, use it as a drop-in replacement for `cat (1)`. + +if command -v bat &> /dev/null; then + alias cat='bat' + + # Use it on man pages too. + export MANPAGER="sh -c 'col -bx | bat -l man -p'" + export MANROFFOPT="-c" +fi + ## # Editors & terminals. @@ -72,6 +83,9 @@ alias gti=git # Setting up PS1. PS1='\u:\w$(__git_ps1 "\[\033[0;32m\]@%s\[\033[0m\]\]") $ ' +# Introduce `cclip` as a fast way to use `xclip` but selecting the clipboard. +alias cclip='xclip -selection clipboard' + ## # Programming languages and environments. -- cgit v1.2.3