Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
WIP _units
- X-seq: zsh-users 30729
- From: christopher@xxxxxxxxx
- To: zsh-users@xxxxxxx
- Subject: WIP _units
- Date: Tue, 28 Jul 2026 22:28:56 +0200
- Archived-at: <https://zsh.org/users/30729>
- List-id: <zsh-users.zsh.org>
Hello,
i'm trying to update _units to allow completion for e.g. `units area_<TAB>`
which currently breaks with the underscore. I couldn't make out what i have
to add to compadd to make this work.
Any suggestions?
Subject: [PATCH] _units
* include new files which can be updated via units_cur from
/var/lib/units.
* allow completion for units with an underscore in their name.
---
Completion/Unix/Command/_units | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/Completion/Unix/Command/_units b/Completion/Unix/Command/_units
index 6d86f4dc3..980661514 100644
--- a/Completion/Unix/Command/_units
+++ b/Completion/Unix/Command/_units
@@ -38,14 +38,15 @@ compset -S '[^[:alnum:]]*'
local datfile
local -a testfiles
testfiles=(
- /usr/share/units.dat # GNU on Fedora
- /usr/share/units/units.dat # on gentoo
- /usr/share/units/definitions.units # on Debian, units 2.00 and newer
- /usr/local/share/units.dat # GNU DIY install
- /usr/share/lib/unittab # Solaris
- /usr/share/misc/units.lib # OpenBSD [as of 2020]; also FreeBSD 9.1
- /usr/share/misc/definitions.units # FreeBSD 12.1
- /usr/share/misc/units.dat # on Debian, units 1.88 and older
+ /usr/share/units.dat # GNU on Fedora
+ /usr/share/units/units.dat # on gentoo
+ /usr/share/units/definitions.units # on Debian, units 2.00 and newer
+ /var/lib/units/*.units # on Debian, updates via units_cur
+ /usr/local/share/units.dat # GNU DIY install
+ /usr/share/lib/unittab # Solaris
+ /usr/share/misc/units.lib # OpenBSD [as of 2020]; also FreeBSD 9.1
+ /usr/share/misc/definitions.units # FreeBSD 12.1
+ /usr/share/misc/units.dat # on Debian, units 1.88 and older
)
datfile=${opt_args[-f]:-${opt_args[--file]}}
@@ -67,7 +68,7 @@ all=($(awk '$1 !~ /^[\/#]/ { print $1 }' $datfile))
# prefixes end in a -
pfxs=(${${all:#^[[:alnum:]]##-}%%-})
# units may include regular or piecewise linear functions
-units=(${${all:#^[[:alnum:]]##([\(\]]*|)}%%\(*})
+units=(${${all:#^[0-9A-z_]##([\(\]]*|)}%%\(*})
if (( ${#units} )); then
_alternative 'unitprefixes:unit prefix:compadd -S "" -a pfxs' \
--
2.53.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author