diff options
author | hjpotter92 <hjpotter92@users.noreply.github.com> | 2020-12-31 15:37:28 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-31 11:07:28 +0100 |
commit | 0e7c81316cab30d28d362f69ddc72be83029ac34 (patch) | |
tree | 3dc9a9e8ea051fe5f26e5cee1c5b432742a5011e /plugins/grc | |
parent | a4a79eaa8cdf39f35dcd1753b973e830ff7b00b8 (diff) | |
download | zsh-0e7c81316cab30d28d362f69ddc72be83029ac34.tar.gz zsh-0e7c81316cab30d28d362f69ddc72be83029ac34.tar.bz2 zsh-0e7c81316cab30d28d362f69ddc72be83029ac34.zip |
feat(grc): source `grc.zsh` instead of hard-coding its content (#9553)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
Diffstat (limited to 'plugins/grc')
-rw-r--r-- | plugins/grc/README.md | 28 | ||||
-rw-r--r-- | plugins/grc/grc.plugin.zsh | 49 |
2 files changed, 14 insertions, 63 deletions
diff --git a/plugins/grc/README.md b/plugins/grc/README.md index dfda41466..515e87640 100644 --- a/plugins/grc/README.md +++ b/plugins/grc/README.md @@ -10,28 +10,6 @@ plugins=(... grc) ## Commands -The following commands are wrapped by `grc` so that their output is automatically colored: - -- `cc` -- `configure` -- `cvs` -- `df` -- `diff` -- `dig` -- `gcc` -- `gmake` -- `ifconfig` -- `iwconfig` -- `last` -- `ldap` -- `make` -- `mount` -- `mtr` -- `netstat` -- `ping` -- `ping6` -- `ps` -- `traceroute` -- `traceroute6` -- `wdiff` -- `whois` +The plugin sources the bundled alias generator from the installation, available at `/etc/grc.zsh`. +The complete list of wrapped commands may vary depending on the installed version of `grc`, look +at the file mentioned above (`/etc/grc.zsh`) to see which commands are wrapped. diff --git a/plugins/grc/grc.plugin.zsh b/plugins/grc/grc.plugin.zsh index 6a52ec568..b709b9e02 100644 --- a/plugins/grc/grc.plugin.zsh +++ b/plugins/grc/grc.plugin.zsh @@ -1,44 +1,17 @@ -# Adapted from: https://github.com/garabik/grc/blob/master/grc.zsh +#!/usr/bin/env 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 +# common grc.zsh paths +files=( + /etc/grc.zsh # default + /usr/local/etc/grc.zsh # homebrew ) -# Set alias for supported commands -for cmd in $cmds; do - if (( $+commands[$cmd] )); then - eval "function $cmd { - grc --colour=auto \"${commands[$cmd]}\" \"\$@\" - }" +# verify the file is readable and source it +for file in $files; do + if [[ -r "$file" ]]; then + source "$file" + break fi done -# Clean up variables -unset cmds cmd +unset file files |