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 <hjpotter92+github@gmail.com>
This commit is contained in:
hjpotter92 2020-12-28 20:29:22 +05:30
parent 70f4178f37
commit 8275543560
1 changed files with 14 additions and 4 deletions

18
grc.zsh
View File

@ -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