zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH] Show alias values in command completions
Date: Thu, 18 May 2023 23:53:29 +0300	[thread overview]
Message-ID: <20230518205329.39746-3-marlon.richert@gmail.com> (raw)
In-Reply-To: <20230518205329.39746-1-marlon.richert@gmail.com>

Show the value of each alias when descriptions are shown. Enabled by default.
---
 Completion/Zsh/Type/_command_names | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names
index 12cbd69c1..d445be06e 100644
--- a/Completion/Zsh/Type/_command_names
+++ b/Completion/Zsh/Type/_command_names
@@ -4,7 +4,7 @@
 # complete only external commands and executable files. This and a
 # `-' as the first argument is then removed from the arguments.

-local args defs expl ffilt
+local args defs expl ffilt verbose

 zstyle -t ":completion:${curcontext}:commands" rehash && rehash

@@ -33,13 +33,19 @@ else
   defs=( "$defs[@]"
     'builtins:builtin command:compadd -Qk builtins'
     "functions:shell function:compadd -k 'functions$ffilt'"
-    'aliases:alias:compadd -Qk aliases'
     'suffix-aliases:suffix alias:_suffix_alias_files'
     'reserved-words:reserved word:compadd -Qk reswords'
     'jobs:: _jobs -t'
     'parameters:: _parameters -g "^*(readonly|association)*" -qS= -r "\n\t\- =[+"'
     'parameters:: _parameters -g "*association*~*readonly*" -qS\[ -r "\n\t\- =[+"'
   )
+
+  if zstyle -T ":completion:${curcontext}:aliases" verbose; then
+    printf -v verbose %s:%s\  ${(@q+)${(kv)aliases}[@]//\:/\\:}
+    defs+=( "aliases:alias:(( $verbose ))" )
+  else
+    defs+=( 'aliases:alias:compadd -Qk aliases' )
+  fi
 fi

 args=( "$@" )
--
2.39.2 (Apple Git-143)



      parent reply	other threads:[~2023-05-18 20:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 20:53 [PATCH] Fix typo in compwid.yo Marlon Richert
2023-05-18 20:53 ` [PATCH] Use zstyle verbose for _parameters descriptions Marlon Richert
2023-05-23 18:27   ` Bart Schaefer
2023-05-24 12:42     ` [PATCH] Fix verbose parameter completion tests Marlon Richert
2023-05-30 18:49     ` [PATCH] Use zstyle verbose for _parameters descriptions Vin Shelton
2023-06-05  7:53       ` Jun T
2023-06-05 20:24         ` Bart Schaefer
2023-06-05 21:12           ` Vin Shelton
2023-06-06  2:09           ` Jun T
2023-05-18 20:53 ` Marlon Richert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230518205329.39746-3-marlon.richert@gmail.com \
    --to=marlon.richert@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).