From f13d71d44f9de9e6e7c0eef02cfda27ff531e5b6 Mon Sep 17 00:00:00 2001
From: Rudis Muiznieks <rudis@sitosis.com>
Date: Thu, 20 Mar 2025 12:38:44 -0500
Subject: [PATCH] improved z.sh a bit

---
 yash/z.sh | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/yash/z.sh b/yash/z.sh
index d60db47..2362ca9 100644
--- a/yash/z.sh
+++ b/yash/z.sh
@@ -8,22 +8,25 @@ _z_exec() {
   return $?
 }
 
+_z_completions() {
+  complete $(_z_exec "select alias from jump_list order by alias")
+}
+
 function completion/z {
-  OPTIONS=( #>#
-  "h:; show help text"
-  "l:; list aliases"
-  "a:; add a new alias"
+  array OPTIONS \
+  "h:; show help text" \
+  "l:; list aliases" \
+  "a:; add a new alias" \
   "r:; remove alias"
-  ) #<#
 
   command -f completion//parseoptions -n
   argnum="${WORDS[#]}"
   if [ "$ARGOPT" = "-" ] && [ "$argnum" -eq 1 ]; then
     command -f completion//completeoptions
   elif [ -z "$ARGOPT" ] && [ "$argnum" -eq 1 ]; then
-    complete -T $(_z_exec "select alias from jump_list")
+    _z_completions
   elif [ "$ARGOPT" = "r" ] && [ "$argnum" -eq 2 ]; then
-    complete -T $(_z_exec "select alias from jump_list")
+    _z_completions
   elif [ "${WORDS[2]}" = "-a" ] && [ "$argnum" -eq 3 ]; then
     complete -T -S '/' -d
   fi