Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Feature request – substitutions similar to +, -, :+, :-
Hello
I constantly save lines of code by using +,-,:+,:- substitutions. Example: there's "$theme[button-color]", which can be empty, so no need for $reset_color. Solution:
button_txt="$theme[button-color]My Button${theme[button-color]:+$reset_color}"
Sometimes I was needing similar substitution but checking for concrete value. So, substitute "abc" if value is "xyz", etc. However it's a hard time to find a place in the substitution where the value could be specified. However, a step in right direction would be boolean test for 1 or 0, or maybe like in zstyle also for true/false, yes/no.
So this would be possible:
echo "I'm ${${theme[use-name]:&Patrick}:-a subscriber}, hello."
:& would substitute on "1", not substitute otherwise, so also not for "". Analogically :^ would substitute on "0". Those substitutions would definitely often save lines of code.
--
Sebastian Gniazdowski
psprint /at/ zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author