grc.plugin.zsh 578 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Adapted from: https://github.com/garabik/grc/blob/master/grc.zsh

if [[ "$TERM" = dumb ]] || (( ! $+commands[grc] )); then
  return
fi

# Supported commands
cmds=(
  cc
  configure
  cvs
  df
  diff
  dig
  gcc
  gmake
  ifconfig
  iwconfig
  last
  ldap
  make
  mount
  mtr
  netstat
  ping
  ping6
  ps
  traceroute
  traceroute6
  wdiff
  whois
)

# Set alias for supported commands
for cmd in $cmds; do
  if (( $+commands[$cmd] )); then
    eval "function $cmd {
      grc --colour=auto \"${commands[$cmd]}\" \"\$@\"
    }"
  fi
done

# Clean up variables
unset cmds cmd