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

PATCH: _globquals: Say what the digit is when completing modification time qualifiers



How about something like this too? It changes the completion output to
say what the digit means.

% *(m<tab>
=== time specifier
M  -- months
h  -- hours
m  -- minutes
s  -- seconds
w  -- weeks
=== sense
+  -- more than
-  -- less than
=== digit (days)

% *(mM<tab>
=== digit (months)


---
 Completion/Zsh/Type/_globquals |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals
index 778dfa8..b47a34d 100644
--- a/Completion/Zsh/Type/_globquals
+++ b/Completion/Zsh/Type/_globquals
@@ -114,6 +114,10 @@ while [[ -n $PREFIX ]]; do
     if ! compset -P '([Mwhms]|)([-+]|)<->'; then
       # complete/skip relative time spec
       alts=()
+      () {
+      local timespec=$PREFIX[1]
+      local -A specmap
+      specmap=( M months w weeks h hours m minutes s seconds '' days )
       if ! compset -P '[Mwhms]' && [[ -z $PREFIX ]]; then
         alts+=(
           "time-specifiers:time specifier:\
@@ -122,7 +126,8 @@ while [[ -n $PREFIX ]]; do
       if ! compset -P '[-+]' && [[ -z $PREFIX ]]; then
         alts+=("senses:sense:((-\:less\ than +\:more\ than))")
       fi
-      alts+=('digits:digit: ')
+      alts+=('digits:digit ('${${specmap[$timespec]}:-invalid time specifier}'): ')
+      }
       _alternative $alts
       return
     fi
-- 
1.7.5.4



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