2
0
mirror of https://github.com/garabik/grc.git synced 2024-10-28 17:41:01 +01:00
bash-color-grc/grc.zsh
hjpotter92 8275543560 Add completions for aliases when defined for zsh.
More description available on github thread:
https://github.com/ohmyzsh/ohmyzsh/issues/6954

Signed-off-by: hjpotter92 <hjpotter92+github@gmail.com>
2020-12-28 20:29:22 +05:30

100 lines
1.0 KiB
Bash

#!/usr/bin/env zsh
if [ "$TERM" = dumb ] || (( ! $+commands[grc] )); then
return
fi
# 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
)
function setup_alias() {
local name="$1"
local path="$(which "$name")"
$name() {
grc --colour=auto $commands[$0] "$@"
}
compdef "_${name}" "$name"
}
# Set alias for available commands.
for cmd in $cmds ; do
if (( $+commands[$cmd] )) ; then
setup_alias $cmd
fi
done
# Clean up variables
unset cmds cmd setup_alias