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

Re: Alternate patch Re: PATCH: New prompt themes



Bart Schaefer wrote:

> That's why the prompt themes created by bash2zshprompt install a precmd
> function that includes "setop promptsubst", and why I patched several of

I hadn't thought of doing it that way and had only read the text not the patch in your message so hadn't seen it. I agree with your past comments about stomping on precmd though and think it is better not to use precmd just for one setopt which doesn't need to be run every time the prompt is printed anyway.
 
> Just do
>         [[ $HOST == (${(j(|))~normal_hosts}) ]] && host=""

That works well, thanks.

Bart Schaefer wrote:
> I'm not sure that it's that useful to factor out the prefix "prompt" from
> each of the strings in prompt_opts, but I'm not going to change that here.

I did that because it seemed an easy way to restrict it to the prompt options.

> Further, I might suggest that instead of an assoc. array with both set and
> unset values, just use a regular array of only the values that are meant to
> be set; e.g. one command instead of a loop:
>   setopt noprompt{bang,cr,percent,subst} prompt$^prompt_opts
> However, I didn't make that change either.

That probably is better. An alternative patch to do it that way follows. The only thing I'm not sure about is whether it is wise that promptcr is controlled by the prompt themes. I'd consider it to be down to personal preference whether it's set or not. I also can't see that it could be crucial to a particular theme so you might want to remove cr from the brace expansion.

Incidentally, I had to use prompt${^prompt_opts[@]} instead of what you suggested because after emulate -R ksh, only the first word in the array would be expanded.

*** Functions/Prompts/promptinit.bak	Wed Oct 20 18:25:20 1999
--- Functions/Prompts/promptinit	Wed Oct 20 18:37:18 1999
***************
*** 34,40 ****
    prompt_newline=$(echo -ne "\n%{\r%}")
  }
  
! prompt () {
    emulate -L zsh
    local opt preview theme usage old_theme
  
--- 34,40 ----
    prompt_newline=$(echo -ne "\n%{\r%}")
  }
  
! set_prompt() {
    emulate -L zsh
    local opt preview theme usage old_theme
  
***************
*** 103,108 ****
--- 103,117 ----
         promptzzzz=$reset_color
         ;;
    esac
+ }
+ 
+ prompt() {
+   local prompt_opts
+   
+   set_prompt "$@"
+   
+   (( $#prompt_opts )) &&
+       setopt noprompt{bang,cr,percent,subst} prompt${^prompt_opts[@]}
  }
  
  promptinit "$@"



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