0e7c81316cab30d28d362f69ddc72be83029ac34
- Author
- hjpotter92 <hjpotter92@users.noreply.github.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
feat(grc): source `grc.zsh` instead of hard-coding its content (#9553)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
Diff
1diff --git a/plugins/grc/README.md b/plugins/grc/README.md
2index dfda414664df8c42dfe9b8ec4ff22136a310129c..515e876400152242b103ca42c96f82c06320c53d 100644
3--- a/plugins/grc/README.md
4+++ b/plugins/grc/README.md
5@@ -10,28 +10,6 @@ plugins=(... grc)
6
7 ## Commands
8
9-The following commands are wrapped by `grc` so that their output is automatically colored:
10-
11-- `cc`
12-- `configure`
13-- `cvs`
14-- `df`
15-- `diff`
16-- `dig`
17-- `gcc`
18-- `gmake`
19-- `ifconfig`
20-- `iwconfig`
21-- `last`
22-- `ldap`
23-- `make`
24-- `mount`
25-- `mtr`
26-- `netstat`
27-- `ping`
28-- `ping6`
29-- `ps`
30-- `traceroute`
31-- `traceroute6`
32-- `wdiff`
33-- `whois`
34+The plugin sources the bundled alias generator from the installation, available at `/etc/grc.zsh`.
35+The complete list of wrapped commands may vary depending on the installed version of `grc`, look
36+at the file mentioned above (`/etc/grc.zsh`) to see which commands are wrapped.
37diff --git a/plugins/grc/grc.plugin.zsh b/plugins/grc/grc.plugin.zsh
38index 6a52ec56865ffc90614dea36dd2953b588465e62..b709b9e0267cf07b3e9740236e5f0320be8a09c7 100644
39--- a/plugins/grc/grc.plugin.zsh
40+++ b/plugins/grc/grc.plugin.zsh
41@@ -1,44 +1,17 @@
42-# Adapted from: https://github.com/garabik/grc/blob/master/grc.zsh
43+#!/usr/bin/env zsh
44
45-if [[ "$TERM" = dumb ]] || (( ! $+commands[grc] )); then
46- return
47-fi
48-
49-# Supported commands
50-cmds=(
51- cc
52- configure
53- cvs
54- df
55- diff
56- dig
57- gcc
58- gmake
59- ifconfig
60- iwconfig
61- last
62- ldap
63- make
64- mount
65- mtr
66- netstat
67- ping
68- ping6
69- ps
70- traceroute
71- traceroute6
72- wdiff
73- whois
74+# common grc.zsh paths
75+files=(
76+ /etc/grc.zsh # default
77+ /usr/local/etc/grc.zsh # homebrew
78 )
79
80-# Set alias for supported commands
81-for cmd in $cmds; do
82- if (( $+commands[$cmd] )); then
83- eval "function $cmd {
84- grc --colour=auto \"${commands[$cmd]}\" \"\$@\"
85- }"
86+# verify the file is readable and source it
87+for file in $files; do
88+ if [[ -r "$file" ]]; then
89+ source "$file"
90+ break
91 fi
92 done
93
94-# Clean up variables
95-unset cmds cmd
96+unset file files