Skip to content

Commit

Permalink
Add completions for aliases when defined for zsh.
Browse files Browse the repository at this point in the history
More description available on github thread:
ohmyzsh/ohmyzsh#6954

Signed-off-by: hjpotter92 <hjpotter92+github@gmail.com>
  • Loading branch information
hjpotter92 committed Dec 28, 2020
1 parent 70f4178 commit 8275543
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions grc.zsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
if [[ "$TERM" = dumb ]] || (( ! $+commands[grc] )); then
#!/usr/bin/env zsh

if [ "$TERM" = dumb ] || (( ! $+commands[grc] )); then
return
fi

Expand Down Expand Up @@ -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

0 comments on commit 8275543

Please sign in to comment.