Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Adding Global Aliases to completion lists



Jacob Menke wrote on Tue, Mar 12, 2019 at 23:43:51 -0400:
> Hello I was wondering how to add global aliases to completion menu
> selection?

Like this:

diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names
index f8188774d..70b0ddcad 100644
--- a/Completion/Zsh/Type/_command_names
+++ b/Completion/Zsh/Type/_command_names
@@ -29,6 +29,7 @@ else
     "functions:shell function:compadd -k 'functions$ffilt'"
     'aliases:alias:compadd -Qk aliases'
     'suffix-aliases:suffix alias:_suffix_alias_files'
+    'global-aliases:global alias:compadd -Qk galiases'
     'reserved-words:reserved word:compadd -Qk reswords'
     'jobs:: _jobs -t'
     'parameters:: _parameters -g "^*(readonly|association)*" -qS= -r "\n\t\- =[+"'

Note that an alias does not have to be global in order to be able to be used in
command position; that is: depending on what your alias does, it might be
better to simply remove the -g from its definition.

> This is the debugging output from ^Xh when I want to add these completion
> items.
> 
> tags in context :completion::complete:-command-::
>     commands builtins functions aliases suffix-aliases reserved-words jobs parameters parameters  (_command_names _autocd)

Thanks for including this; it made it easy to find the right function.

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author