Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] sysctl: support completion with the dot delimiter on linux
- X-seq: zsh-workers 53144
- From: Eric Cook <llua@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] sysctl: support completion with the dot delimiter on linux
- Date: Mon, 14 Oct 2024 11:31:54 -0400
- Archived-at: <https://zsh.org/workers/53144>
- List-id: <zsh-workers.zsh.org>
- Ui-outboundreport: notjunk:1;M01:P0:BgrNYGzV+TI=;Qd+Qs92DGO3AI3NI96Ovmk090Ss jEoPB77Lpl1FYwDw9v5PhUlRlsFYdB4xPjTprBTOvsoYspwH8lce7nDS4VRWVMRe965/rsdNm Fqj5rFH0/jsLo7kIHVPGvDANyW1CEY8cym2gKKHnOiTydrYprANfQBw0DCt4dIoHwX2LXpYGI TPkjeF2PirFsgh4Fuu/oIfmzTv6+eAiED3N8H6I2HlPTUriMCoUa/rWgFhmMg3N58nxSg24Cv eDbTqGnMuU/1LKH88Umz+v2HvTenNhZnY98Bfl3pBY1RGJsADUUJXokcUDA/tAPZx874h68Xs ABpskffT6+ul6X7fTEpm79j4ud9V3uwZ1XmuJu9eE/zXpPebkz/+DnedSu48dM5BNwd2+4f2w zIwbKo8nF2m2/Zu+Wal7Jnsk6L1JqCDeeOhCdUQUBUS+2doL5oU122S90ubOcBsmM1q6ijI0R Xs+BdB7qPF52N9wZoXvmXwlkQSOKtHmZk5ZGf/Rov4o+l0GO1gHt4nFahClwWh1xBFpvSKXl2 F9JuoLtrrkk+8OB3KXMaddWdOdih7BBLCIsg+atJqodY/F5URQFKJyVCzPQK/QNA3FuUDNk5T vLqzg9XgBRvE0ZzkAZns5KQpRXxTumD67Wt4I6B1+hSYHsM8vnODOqI5IRRnXclO2NakjLhZ1 yBiaW0GTtUqalWllgYotEke+IckLDrdX6E3vZ7sgnI9yVAeYTPCVzwY0S4dyElknAk8qAA9IQ Gp/me1nEGwMCLLDnN3ZmQ+QOs79usghHdFK7DsTSLgKUa0BiN74WJW0wJV63q0UKoJc1JUUt9 1fWtc/yza/vuzM4sfB0tptwA==
This was a request from irc. historically zsh did completion using / as the
delimiter (via _files) which while supported, kinda foreign to users of other
OSes and how sysctl examples are commonly shown online.
As is the patch changes the delimiter used to `.' but will still perform
completion should `/' be used, along with a style to get the old behavior
by default. that style will be ignored should the user attempt completion
with the other delimiter.
If changing the delimiter to `.' is undesired, i can swap them around.
(the globbing of /proc/sys/ was deemed faster than using `sysctl -aN' FWIW)
---
diff --git a/Completion/Unix/Command/_sysctl b/Completion/Unix/Command/_sysctl
index 442953c4d..09995c98e 100644
--- a/Completion/Unix/Command/_sysctl
+++ b/Completion/Unix/Command/_sysctl
@@ -23,10 +23,18 @@ case $OSTYPE in
else
args=( ${args:#((#s)|*\))(\*|)--*} ) # remove long options
fi
+ local delimiter=.
+ sysctlvars=( /proc/sys/**/*(.e*'REPLY=${REPLY#/proc/sys/}'*) )
+ if zstyle -t ":completion:${curcontext}:argument-rest" delimiter / || (( ${words[CURRENT][(Ie)/]} )); then
+ delimiter=/
+ else
+ sysctlvars=(${sysctlvars//\//.})
+ fi
+
_arguments -S -A "-*" : $args \
'(- :)'{-h,--help}'[display help text and exit]' \
'(- :)'{-V,--version}'[display version info and exit]' \
- '*:sysctl variable:_files -W /proc/sys'
+ "*:sysctl variable:_multi_parts -i -S = -q $delimiter sysctlvars"
;;
freebsd<14->.*)
args+=(
Messages sorted by:
Reverse Date,
Date,
Thread,
Author