mirror of https://github.com/garabik/grc.git
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:
parent
70f4178f37
commit
8275543560
18
grc.zsh
18
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
|
||||
|
|
Loading…
Reference in New Issue