sh: Add bat to cat alias
Always call `bat` when we invoke `cat`. There is not ever a time when I want to use the bog standard `cat` in preference to `bat`. However, on the very slight off-chance there is, we still have a fallback alias on `rcat` which invokes 'raw' cat instead.
This commit is contained in:
parent
f04340acbd
commit
528a4e7fce
1 changed files with 20 additions and 0 deletions
20
sh/.config/sh/alias.d/batcat.sh
Normal file
20
sh/.config/sh/alias.d/batcat.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env sh
|
||||
# Make cat actually call bat if it exists.
|
||||
# Give `rcat` as 'rawcat' replacement if needed.
|
||||
#
|
||||
# Mostly taken from https://github.com/fdellwing/zsh-bat
|
||||
# sans MANPAGER
|
||||
#
|
||||
# shellcheck disable=SC2139 # (Expands when defined not used)
|
||||
# We actively want it to check when defined so this is fine.
|
||||
|
||||
# Save the original system `cat` under `rcat`
|
||||
alias rcat="$(which cat)"
|
||||
if command -v batcat >/dev/null 2>&1; then
|
||||
# For Ubuntu and Debian-based `bat` packages
|
||||
# the `bat` program is named `batcat` on these systems
|
||||
alias cat="$(which batcat)"
|
||||
elif command -v bat >/dev/null 2>&1; then
|
||||
# For all other systems
|
||||
alias cat="$(which bat)"
|
||||
fi
|
Loading…
Reference in a new issue