about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarlon Richert <marlon.richert@gmail.com>2023-05-18 23:53:29 +0300
committerOliver Kiddle <opk@zsh.org>2023-05-21 03:14:27 +0200
commit9a5f213573fbda6a6d23e985113eaeb849d4ee6d (patch)
tree19ce253b9dc599be3bdd1baae577b0f6c6ac2f74
parent1f64d0912720ba35f92020c3c1e128039cac5df8 (diff)
downloadzsh-9a5f213573fbda6a6d23e985113eaeb849d4ee6d.tar.gz
zsh-9a5f213573fbda6a6d23e985113eaeb849d4ee6d.tar.xz
zsh-9a5f213573fbda6a6d23e985113eaeb849d4ee6d.zip
51759: Show alias values in command completions
Show the value of each alias when descriptions are shown. Enabled by default.
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Zsh/Type/_command_names10
2 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d4c68038..a85706e15 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2023-05-21  Oliver Kiddle  <opk@zsh.org>
 
+	* Marlon Richert: 51759: Completion/Zsh/Type/_command_names:
+	Show alias values in command completions
+
 	* Marlon Richert: 51760: Doc/Zsh/compwid.yo: r and R were listed
 	in the wrong order.
 
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=( "$@" )