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

Re: Submitting vcs_info function



On 2008-09-21 at 02:39 -0700, Phil Pennock wrote:
> Reports screen WINDOW, SHLVL, previous command exit status (including
> signal name if sig-exit), count of backgrounded jobs, repository
> information plus the usual bits.  Has some automatic screen titling
> stuff in the prompt too.

Anyone have any recommendations for using zstyle with prompts?

I've gone for:
  :prompt:<theme>:<$TERM>:<colour|mono>
in the absence of any better ideas.  This removes a TODO from the file,
to move the employer logic out into a style.

I sometimes make an effort to sync my configs a bit between the setups
and it's useful to have the employer in my prompt; or at least, at
3.30am after the pager goes off and before coffee, I tend to think so.
Besides, I use a really-cheesy multi-coloured tag reminiscent of my
employer's logo, which makes people groan.  :)

----------------------------8< cut here >8------------------------------
--- posted-prompt	Sun Sep 21 02:55:21 2008
+++ prompt_pdp-vcs_setup	Sun Sep 21 02:52:38 2008
@@ -1,7 +1,7 @@
 # Phil's prompt setup for zsh
 #
 # $HeadURL: https://svn.spodhuis.org/ksvn/spodhuis-tools/zsh/site-functions/prompt_pdp-vcs_setup $
-# $Id: prompt_pdp-vcs_setup 239 2008-09-20 21:37:30Z xxx@xxxxxxxxxxxx $
+# $Id: prompt_pdp-vcs_setup 240 2008-09-21 09:52:38Z xxx@xxxxxxxxxxxx $
 #
 # Installs somewhere in fpath; typically one of:
 #  /usr/globnix/share/zsh/site-functions/prompt_pdp-vcs_setup
@@ -90,7 +90,7 @@
 function prompt_pdp-vcs_setup {
 	local -h name root host mach line time level error jobc pathdisp vcs
 	local -h p1 prefix='' trunclen=40
-	local -h employer
+	local -h employer employer_domain
 	local -h docolour=:
 	[[ $1 == update ]] && docolour=false
 
@@ -131,8 +131,13 @@
 	zstyle ':vcs_info:*' formats %b %s
 	zstyle ':vcs_info:*' actionformats "%b|%a" %s
 
-# Employer-dependent $HOST check elided from post
+	local style_ctx=":prompt:pdp-vcs:$TERM:"
+	$docolour && style_ctx+=colour || style_ctx+=mono
 	employer=''
+	zstyle -s "$style_ctx" employer-domain employer_domain
+	if [[ -n $employer_domain && $HOST == *.$employer_domain ]]; then
+		zstyle -s "$style_ctx" employer-prompt employer
+	fi
 
 	root="$(prompt_pdp-vcs_hl root %n)"
 	name="$(prompt_pdp-vcs_hl name "%(#.${root}.%n)")"
----------------------------8< cut here >8------------------------------



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