From 827554356082b94ce458f1f903a554de5bad796c Mon Sep 17 00:00:00 2001 From: hjpotter92 Date: Mon, 28 Dec 2020 20:29:22 +0530 Subject: [PATCH] Add completions for aliases when defined for zsh. More description available on github thread: https://github.com/ohmyzsh/ohmyzsh/issues/6954 Signed-off-by: hjpotter92 --- grc.zsh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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