From 0e7c81316cab30d28d362f69ddc72be83029ac34 Mon Sep 17 00:00:00 2001 From: hjpotter92 Date: Thu, 31 Dec 2020 15:37:28 +0530 Subject: feat(grc): source `grc.zsh` instead of hard-coding its content (#9553) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/grc/grc.plugin.zsh | 49 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) (limited to 'plugins/grc/grc.plugin.zsh') 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 -- cgit v1.2.3-70-g09d2