zsh-workers
 help / color / mirror / code / Atom feed
* Feature request – substitutions similar to +, -, :+, :-
@ 2017-11-18 18:05 Sebastian Gniazdowski
  2017-11-18 18:22 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 10+ messages in thread
From: Sebastian Gniazdowski @ 2017-11-18 18:05 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-12-05  9:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-18 18:05 Feature request – substitutions similar to +, -, :+, :- Sebastian Gniazdowski
2017-11-18 18:22 ` Sebastian Gniazdowski
2017-11-18 18:46   ` Bart Schaefer
     [not found]   ` <etPan.5a10805d.57d72d7c.137@AirmailxGenerated.am>
2017-11-25 11:15     ` Sebastian Gniazdowski
2017-12-03  9:11       ` Ternary expression in Zsh (was: Feature request – substitutions similar to +, -, :+, :-) Sebastian Gniazdowski
2017-12-05  6:55         ` Stephane Chazelas
2017-12-05  8:06           ` Tom M.
2017-12-05  9:04             ` Bart Schaefer
2017-12-05  8:24         ` Sebastian Gniazdowski
2017-12-05  9:05           ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).