zsh: optimize setOptions with array-based loops

Replace individual setopt statements with array-based loops for cfg.setOptions.
Use lib.hm.zsh.define for consistent array formatting and add unset statements
to clean up temporary variables, improving consistency with other zsh optimizations.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-09-26 16:48:12 -05:00
parent 04f672b5db
commit 3aaf340173
2 changed files with 7 additions and 2 deletions

View file

@ -17,7 +17,6 @@ let
;
cfg = config.programs.zsh;
bindkeyCommands = {
emacs = "bindkey -e";
viins = "bindkey -v";
@ -501,7 +500,12 @@ in
(lib.mkIf (cfg.setOptions != [ ]) (
mkOrder 950 ''
${concatStringsSep "\n" (map (option: "setopt ${option}") cfg.setOptions)}
# Set shell options
${lib.hm.zsh.define "set_opts" cfg.setOptions}
for opt in "''${set_opts[@]}"; do
setopt "$opt"
done
unset opt set_opts
''
))