I'm trying to change an element of a zsh associative array, but I can't find any clues on the correct syntax.
The PHP equivalent would be
$assoc['key'] = 'newvalue';
but how can I do this in zsh?
The documentation seems to be very confusing on this, as it assumes that once you've set up an associative array, you never want to change it.
EDIT: this is what I'm trying to do
% noglob ZSH_HIGHLIGHT_STYLES[globbing]='fg=yellow'
zsh: command not found: ZSH_HIGHLIGHT_STYLES[globbing]=fg=yellow
$ZSH_HIGHLIGHT_STYLES
is defined by the zsh-syntax-highlighting plugin.
One of the advantages of zsh over bash 3 is the support of “associative arrays,” a data structure known as hash tables or dictionaries in other languages.
Zsh is built on top of bash thus it has additional features. Zsh is the default shell for macOS and Kali Linux. Zsh provides the user with more flexibility by providing various features such as plug-in support, better customization, theme support, spelling correction, etc.
Bash indexed arrays are zero based, this means that to access the first element we have to use the index zero.
It's actually pretty simple, assuming you have an associative array.
typeset -A assoc
assoc[key]=newvalue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With