Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [RFC][PATCH] `newuser` prompt theme
- X-seq: zsh-workers 48581
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Cc: Marlon <marlon.richert@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [RFC][PATCH] `newuser` prompt theme
- Date: Wed, 14 Apr 2021 18:07:31 -0700
- Archived-at: <https://zsh.org/workers/48581>
- In-reply-to: <20210414140909.GG3882@tarpaulin.shahaf.local2>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7am=oS7FEpOOc=vUDLWN3iVQ8--ewqDOJLS2TheDag6TQ@mail.gmail.com> <7E71FA83-356E-448B-9726-02DF3FF5BD14@gmail.com> <CAH+w=7ZBsfiJwC-PYBvOVgrgGmC4RTYt9rRroGiqo_rzVSBJHQ@mail.gmail.com> <873D08A9-F321-474A-8440-CCE7DCCBA529@gmail.com> <20210414120551.GA3882@tarpaulin.shahaf.local2> <6CEA4F3E-9A64-44E1-9121-FA9D5E053AB5@gmail.com> <20210414140909.GG3882@tarpaulin.shahaf.local2>
On Wed, Apr 14, 2021 at 7:09 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Make defaults overridable.
>
> Don't trample user settings (e.g., someone explicitly setting that style
> to a false value for that same context, or for the context «:vcs_info*»,
> which is less specific than the context you use and thus would be shadowed).
I have a half-finished script to initialize interesting completion
styles. In that script I test the styles to be set by using "zstyle
-g", and then only if that fails, set the value I want.
emulate zsh -o extendedglob -c 'default_zstyle() {
local -a patstyle defn
if [[ "$1" = (-e|-|--) ]]
then patstyle=( "$2" "$3" )
else patstyle=( "$1" "$2" )
fi
! zstyle -T "${patstyle[@]}" ||
zstyle -g defn "${patstyle[@]}" ||
zstyle "$@"
}'
Thus:
default_zstyle -e ':vcs_info:*' formats '
reply=( "%u%c$( prompt_newuser_format start branch repo )" )
'
The "zstyle -T" treats the new style's pattern as a context and tries
to look up an existing style; that mostly works. "zstyle -g" is just
a failsafe.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author