Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: New prompt themes



On Oct 19,  8:11pm, Oliver Kiddle wrote:
> Subject: PATCH: New prompt themes
> 
> I came across one problem when writing my own prompt setup scripts.
> Basically, the prompt_subst option is disabled in my setup but was
> required by a prompt which I wanted to create. I know I could just
> change my own setup but I think that the system should be independant
> of people's options. The trouble is that the prompt function uses
> emulate -L so I can't set options in my prompt setup function.

That's why the prompt themes created by bash2zshprompt install a precmd
function that includes "setop promptsubst", and why I patched several of
the themes Adam supplied (before that version of bash2zshprompt existed)
to have such a precmd.  (Article 8271.)

> The following patch is a possible solution. It uses an associative
> array to return the prompt options to a wrapper function which sets
> them. For example, you can do:
> prompt_opts=( subst set percent set bang unset )

I posted code to do a similar thing some while back ... article 6185.

> The sickly colours of some of the example prompts also made me wonder
> whether we should maybe separate the colour control from the prompt
> content.

Adam has said he intends to do this eventually.

> Incidentally, I also think that Misc/colors should use associative
> arrays - it would be useful to be able to do $fg[$color].

I mentioned this privately to Adam last week and he agreed it would
be a good idea.

> I was wondering if anyone knows a better way to match the hostnames to
> the array. I have an array ($normal_hosts) listing hosts for which I
> don't want to include the hostname in the prompt. It'd be nice if this
> array could be treated as a list of patterns to be matched instead of
> fixed strings.

Instead of

> +  for a in $normal_hosts; do
> +    [[ $HOST == $a ]] && host=""
> +  done

Just do

	[[ $HOST == (${(j(|))~normal_hosts}) ]] && host=""

The same will work for $normal_users.



Messages sorted by: Reverse Date, Date, Thread, Author