From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25270 invoked from network); 13 Oct 2007 13:31:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Oct 2007 13:31:19 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 39223 invoked from network); 13 Oct 2007 13:31:09 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Oct 2007 13:31:09 -0000 Received: (qmail 7183 invoked by alias); 13 Oct 2007 13:31:06 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23947 Received: (qmail 7158 invoked from network); 13 Oct 2007 13:31:06 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Oct 2007 13:31:06 -0000 Received: (qmail 38907 invoked from network); 13 Oct 2007 13:31:05 -0000 Received: from acolyte.scowler.net (216.254.112.45) by a.mx.sunsite.dk with SMTP; 13 Oct 2007 13:30:59 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id 5A5435C468; Sat, 13 Oct 2007 09:30:56 -0400 (EDT) Date: Sat, 13 Oct 2007 09:30:57 -0400 From: Clint Adams To: wgscott@chemistry.ucsc.edu Cc: Matthew Wozniski , zsh-workers@sunsite.dk Subject: Re: precmd, preexec, and supplied prompt themes Message-ID: <20071013133057.GA1500@scowler.net> Mail-Followup-To: wgscott@chemistry.ucsc.edu, Matthew Wozniski , zsh-workers@sunsite.dk References: <20071012215906.GA8935@mastermind> <20071012152257.91edf6d3.wgscott@chemistry.ucsc.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071012152257.91edf6d3.wgscott@chemistry.ucsc.edu> User-Agent: Mutt/1.5.16 (2007-06-11) [moving to -workers] > Check out the zsh man page, section SPECIAL FUNCTIONS, or just search > for 'hook function'. The long and short of it is that the prompt > themes should be using > > typeset -a precmd_functions > precmd_functions += my_prompt_precmd Since there is no unregistration hook, how would you avoid the problem of precmd_functions containing (my_prompt_precmd her_prompt_precmd his_prompt_precmd my_prompt_precmd) when switching back and forth? The clobbering below should now appear more explicit. Index: Functions/Prompts/prompt_clint_setup =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_clint_setup,v retrieving revision 1.6 diff -u -r1.6 prompt_clint_setup --- Functions/Prompts/prompt_clint_setup 7 Sep 2006 18:09:44 -0000 1.6 +++ Functions/Prompts/prompt_clint_setup 13 Oct 2007 13:26:07 -0000 @@ -36,7 +36,7 @@ [[ -n "$WINDOW" ]] && p_win="$pc['\(']%{$fg_bold[$pcc[4]]%}$WINDOW$pc['\)']" p_userpwd="$pc['<']%{$fg_no_bold[$pcc[3]]%}%n@%m$p_win%{$fg_bold[$pcc[5]]%}:%{$fg_no_bold[$pcc[4]]%}%~$pc['>']" - [[ -f /proc/apm ]] && p_apm="%(2v.-%2v-.)" + p_git="%(2v.-%U%2v%u-.)" p_shlvlhist="%{$reset_color%}zsh%(2L./$SHLVL.) %B%h%b " p_rc="%(?..[%?%1v] )" @@ -46,34 +46,28 @@ prompt="$p_date$p_tty$p_plat$p_ver $p_userpwd -$p_shlvlhist$p_rc$p_apm$p_end" +$p_shlvlhist$p_rc$p_git$p_end" PS2='%(4_.\.)%3_> %E' - [[ -f /proc/apm ]] && - precmd () { prompt_clint_precmd ; prompt_clint_apm_precmd } || - precmd () { prompt_clint_precmd } + precmd () { prompt_clint_precmd } preexec () { } } prompt_clint_precmd () { setopt noxtrace noksharrays localoptions local exitstatus=$? + local git_dir git_ref + psvar=() [[ $exitstatus -ge 128 ]] && psvar[1]=" $signals[$exitstatus-127]" || psvar[1]="" [[ -o interactive ]] && jobs -l -} - -prompt_clint_apm_precmd () { - setopt noxtrace noksharrays localoptions - local bat ac - - bat=${${="$( /dev/null) || return + git_ref=$(git-symbolic-ref HEAD 2> /dev/null) || git_ref="(no branch)" + psvar[2]=${ref#refs/heads/} - [[ $bat == ("100%"|"-1%") ]] && psvar[2]=() || psvar[2]="$ac$bat" } prompt_clint_setup "$@"