bash-color-grc/grc.zsh

101 lines
1.0 KiB
Bash
Raw Normal View History

#!/usr/bin/env zsh
if [ "$TERM" = dumb ] || (( ! $+commands[grc] ))
then
2020-11-18 16:44:59 +01:00
return
fi
2015-10-10 16:35:08 +02:00
2020-11-18 16:44:59 +01:00
# Supported commands
cmds=(
as
ant
blkid
cc
configure
cvs
df
diff
dig
dnf
docker
docker-compose
docker-machine
du
env
fdisk
findmnt
free
g++
gas
gcc
getfacl
getsebool
gmake
id
ifconfig
iostat
ip
iptables
iwconfig
journalctl
kubectl
last
ldap
lolcat
ld
ls
lsattr
lsblk
lsmod
lsof
lspci
make
mount
mtr
mvn
netstat
nmap
ntpdate
php
ping
ping6
proftpd
ps
sar
semanage
sensors
showmount
sockstat
ss
stat
sysctl
systemctl
tcpdump
traceroute
traceroute6
tune2fs
uptime
vmstat
wdiff
whois
)
2015-10-10 16:35:08 +02:00
function setup_alias() {
local name="$1"
local path="$(which "$name")"
$name() {
grc --colour=auto $commands[$0] "$@"
}
compdef "_${name}" "$name"
}
2020-11-18 16:44:59 +01:00
# Set alias for available commands.
for cmd in $cmds ; do
if (( $+commands[$cmd] )) ; then
setup_alias $cmd
2020-11-18 16:44:59 +01:00
fi
done
2015-10-10 16:35:08 +02:00
2020-11-18 16:44:59 +01:00
# Clean up variables
unset cmds cmd setup_alias