diff --git a/grc.zsh b/grc.zsh index aaaa4b9..6a52b9b 100644 --- a/grc.zsh +++ b/grc.zsh @@ -1,4 +1,6 @@ -if [[ "$TERM" = dumb ]] || (( ! $+commands[grc] )); then +#!/usr/bin/env zsh + +if [ "$TERM" = dumb ] || (( ! $+commands[grc] )); then return fi @@ -77,13 +79,21 @@ cmds=( 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 - alias $cmd="grc --colour=auto $commands[$cmd]" + setup_alias $cmd fi done # Clean up variables -unset cmds cmd - +unset cmds cmd setup_alias