* Re: Submitting vcs_info function
[not found] ` <20080919133411.GN2182@fsst.voodoo.lan>
@ 2008-09-19 14:57 ` Frank Terbeck
0 siblings, 0 replies; 10+ messages in thread
From: Frank Terbeck @ 2008-09-19 14:57 UTC (permalink / raw)
To: zsh workers
[moved to workers]
Frank Terbeck <ft@bewatermyfriend.org>:
> One minor glitch in the list of styles:
Here is another:
Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.85
diff -u -r1.85 contrib.yo
--- Doc/Zsh/contrib.yo 19 Sep 2008 13:50:41 -0000 1.85
+++ Doc/Zsh/contrib.yo 19 Sep 2008 14:55:41 -0000
@@ -581,8 +581,10 @@
function you want to call from tt(precmd) if you want to include up-to-date
information in your prompt (see Variable description below). If an argument
is given, that string will be used instead of tt(default) in the
-user-context field of the style context.)
-sitem(tt(vcs_info_lastmsg))(Outputs the last var(${vcs_info_msg_*_}) value.
+user-context field of the style context.
+)
+item(tt(vcs_info_lastmsg))(
+Outputs the last var(${vcs_info_msg_*_}) value.
Takes into account the value of the use-prompt-escapes style in
var(':vcs_info:formats:command:-all-'). It also only prints tt(max-exports)
values.
@@ -591,8 +593,10 @@
item(tt(vcs_info_printsys) [var(user-context)])(
Prints a list of all
supported version control systems. Useful to find out possible contexts
-(and which of them are enabled) or values for the var(disable) style.)
-sitem(tt(vcs_info_setsys))(Initializes var(vcs_info)'s internal list of
+(and which of them are enabled) or values for the var(disable) style.
+)
+item(tt(vcs_info_setsys))(
+Initializes var(vcs_info)'s internal list of
available backends. With this function, you can add support for new VCSs
without restarting the shell.
)
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20080917203242.GV2182@fsst.voodoo.lan>]
* Re: Submitting vcs_info function
[not found] ` <20080917203242.GV2182@fsst.voodoo.lan>
@ 2008-09-21 9:11 ` Clint Adams
2008-09-21 9:39 ` Phil Pennock
2008-09-21 10:23 ` Frank Terbeck
0 siblings, 2 replies; 10+ messages in thread
From: Clint Adams @ 2008-09-21 9:11 UTC (permalink / raw)
To: zsh-workers
On Wed, Sep 17, 2008 at 10:32:42PM +0200, Frank Terbeck wrote:
> +If you plan to use the information from var(vcs_info) in your prompt (which
> +is its primary use), you need to enable the tt(PROMPT_SUBST) option.
I don't think that this claim is accurate.
Index: Functions/Prompts/prompt_clint_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_clint_setup,v
retrieving revision 1.9
diff -u -r1.9 prompt_clint_setup
--- Functions/Prompts/prompt_clint_setup 17 May 2008 22:42:17 -0000 1.9
+++ Functions/Prompts/prompt_clint_setup 21 Sep 2008 09:07:53 -0000
@@ -15,6 +15,8 @@
local -A pc
local p_date p_tty p_plat p_ver p_userpwd p_apm p_shlvlhist p_rc p_end p_win
+ autoload -Uz vcs_info
+
pcc[1]=${1:-'red'}
pcc[2]=${2:-'cyan'}
pcc[3]=${3:-'green'}
@@ -36,7 +38,7 @@
[[ -n "$WINDOW" ]] && p_win="$pc['\(']%F{$pcc[4]}$WINDOW$pc['\)']"
p_userpwd="$pc['<']%F{$pcc[3]}%n@%m$p_win%F{$pcc[5]}:%F{$pcc[4]}%~$pc['>']"
- p_git="%(2v.-%U%2v%u-.)"
+ p_vcs="%(2v.%U%2v%u.)"
p_shlvlhist="%fzsh%(2L./$SHLVL.) %B%h%b "
p_rc="%(?..[%?%1v] )"
@@ -46,7 +48,7 @@
prompt="$p_date$p_tty$p_plat$p_ver
$p_userpwd
-$p_shlvlhist$p_rc$p_git$p_end"
+$p_shlvlhist$p_rc$p_vcs$p_end"
PS2='%(4_.\.)%3_> %E'
add-zsh-hook precmd prompt_clint_precmd
@@ -63,9 +65,8 @@
[[ -o interactive ]] && jobs -l
- git_dir=$(git-rev-parse --git-dir 2> /dev/null) || return
- git_ref=$(git-symbolic-ref HEAD 2> /dev/null) || git_ref="(no branch)"
- psvar[2]=${git_ref#refs/heads/}
+ vcs_info
+ [[ -n $vcs_info_msg_0_ ]] && psvar[2]="$vcs_info_msg_0_"
}
prompt_clint_setup "$@"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Submitting vcs_info function
2008-09-21 9:11 ` Clint Adams
@ 2008-09-21 9:39 ` Phil Pennock
2008-09-21 10:00 ` Phil Pennock
2008-09-21 10:23 ` Frank Terbeck
1 sibling, 1 reply; 10+ messages in thread
From: Phil Pennock @ 2008-09-21 9:39 UTC (permalink / raw)
To: zsh-workers
On 2008-09-21 at 09:11 +0000, Clint Adams wrote:
> On Wed, Sep 17, 2008 at 10:32:42PM +0200, Frank Terbeck wrote:
> > +If you plan to use the information from var(vcs_info) in your prompt (which
> > +is its primary use), you need to enable the tt(PROMPT_SUBST) option.
>
> I don't think that this claim is accurate.
Ditto. Although it would be nice if vcs_info made all the different
variables available in a $Z_VCS hash or somesuch, so that I didn't need
to zstyle from my prompt.
FWIW, here's a lightly modified version of the prompt I'm using now,
built up over years, originally with help from zefram@ and then later
with some attention to Bart's setup and generally munged about. I
finally updated it to use the new colour codes, since the vcs_info stuff
led to me using more elements of $psvar, deciding to add %(V..)
conditional to check if set and then seeing that CVS had already done
just that. Convenient. :)
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.
----------------------------8< cut here >8------------------------------
# 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@SPODHUIS.ORG $
#
# Installs somewhere in fpath; typically one of:
# /usr/globnix/share/zsh/site-functions/prompt_pdp-vcs_setup
# ~/bin/zsh-functions/
#
# Requires: zsh 4.3.7 or newer (for %(V..) prompt conditional)
zmodload -i zsh/parameter || return 1
function prompt_pdp-vcs_help {
<<EOF
This prompt shows some information always and some when necessary.
The information depends in part upon \$TERM, as does emission of a
title-changing escape sequence (for xterms, etc).
OnDemand: '[num]' showing the SHLVL if not 1.
OnDemand: '{errcode}' or '{SIGNAME}' if previous command not successful.
Backgrounded jobs indication; '-' for none or '<+num>' showing count.
Then: usercode@machine.2ndlevel:tty[time]
OnDemand: VCS repository information
Then: (history-num)
A left-truncated section of the pwd.
The %/# prompt character and a space.
Right-hand prompt: VCS type or absent
TERM=screen: prefix '<WINDOW>' and a screen-magic escape sequence for titling.
Optional prompt setup parameters:
update -- do not reset any colour variables
EOF
}
function prompt_pdp-vcs_precmd {
local exitstatus=$?
emulate -L zsh # ksh_arrays breaks us badly
psvar=()
psvar[1]=SIG
[[ $exitstatus -ge 128 ]] && psvar[1]=SIG$signals[$exitstatus-127]
[[ $psvar[1] == SIG ]] && psvar[1]=$exitstatus
vcs_info
psvar[2]=$#jobstates; [[ $psvar[2] -eq 0 ]] && psvar[2]=''
psvar[3]=$VCS_INFO_message_1_
psvar[4]=$VCS_INFO_message_0_
return $exitstatus
}
function prompt_pdp-vcs_setup__colour {
local endc
typeset -gA prompt_pdp_vcs__hl prompt_pdp_vcs__ehl
prompt_pdp_vcs__hl=()
prompt_pdp_vcs__ehl=()
prompt_pdp_vcs__hl[name]='%F{green}'
prompt_pdp_vcs__hl[mach]='%F{yellow}'
#prompt_pdp_vcs__hl[time]='%F{yellow}'
prompt_pdp_vcs__hl[level]='%U'
prompt_pdp_vcs__ehl[level]='%u'
prompt_pdp_vcs__hl[error]='%B%F{red}'
prompt_pdp_vcs__ehl[error]='%f%b'
prompt_pdp_vcs__hl[jobcount]='%B'
prompt_pdp_vcs__ehl[jobcount]='%b'
# commandcount here
prompt_pdp_vcs__hl[path]='%F{cyan}'
prompt_pdp_vcs__hl[window]='%B%F{magenta}'
prompt_pdp_vcs__ehl[window]='%f%b'
prompt_pdp_vcs__hl[root]='%K{red}'
prompt_pdp_vcs__ehl[root]='%k'
prompt_pdp_vcs__hl[vcstype]='%F{green}'
prompt_pdp_vcs__hl[vcsbranch]='%F{magenta}'
return 1
}
function prompt_pdp-vcs_hl {
local what="$1"; shift
local text="$1"; shift
local start end
start="${prompt_pdp_vcs__hl[$what]}"
if [[ -z $start ]]; then
end=''
else
end="${prompt_pdp_vcs__ehl[$what]}"
: ${end:='%f'}
fi
print -r -- "${start}${text}${end}"
}
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 docolour=:
[[ $1 == update ]] && docolour=false
# this should be set by a style:
local -h hostlabelcount=2
# foo.local stet; foo.example.tld => foo; foo.bar.example.tld => foo.bar
# foo.bar.example.co.cc => foo.bar; BUT foo.example.co.cc => foo.example
# (the last accepted reluctantly as the best that can be done without
# encoding per-TLD hierarchy information)
[[ ${#${HOST//[^\.]/}} -eq 2 ]] && hostlabelcount=1
[[ -n $COLORTERM ]] && $docolour && prompt_pdp-vcs_setup__colour "$@"
case ${TERM} in
(putty|xterm*)
[[ -z $COLORTERM ]] && export COLORTERM="$TERM"
function chpwd { [[ -t 0 ]] || return; print -Pn "\e]2;%n@%${hostlabelcount}m:%~\a" }
$docolour && prompt_pdp-vcs_setup__colour
chpwd
;;
(screen|screen.*)
unfunction chpwd >/dev/null 2>&1 || true
# \x5c is backslash '\'; screen(1) §TITLES
prefix="$(prompt_pdp-vcs_hl window "<$WINDOW>")%{$(print '\ek\e\x5c')%}"
trunclen=33
;;
(cons*|linux)
[[ -z $COLORTERM ]] && export COLORTERM="$TERM"
unfunction chpwd >/dev/null 2>&1 || true
$docolour && prompt_pdp-vcs_setup__colour
;;
(*)
unfunction chpwd >/dev/null 2>&1 || true
;;
esac
zstyle ':vcs_info:*' branchformat %b:%r
zstyle ':vcs_info:*' formats %b %s
zstyle ':vcs_info:*' actionformats "%b|%a" %s
# Employer-dependent $HOST check elided from post
employer=''
root="$(prompt_pdp-vcs_hl root %n)"
name="$(prompt_pdp-vcs_hl name "%(#.${root}.%n)")"
host="$(prompt_pdp-vcs_hl mach "%${hostlabelcount}m")"
line="$(prompt_pdp-vcs_hl line '%l')"
time="$(prompt_pdp-vcs_hl time '[%T]')"
level="%2(L.$(prompt_pdp-vcs_hl level '[%L]').)"
error="%(?..$(prompt_pdp-vcs_hl error '{%v}'))"
jobc="%(2V:<$(prompt_pdp-vcs_hl jobcount '+%2v')>:-)"
cmdc="($(prompt_pdp-vcs_hl commandcount '%!'))"
pathdisp="$(prompt_pdp-vcs_hl path "%${trunclen}<..<%~%<<")"
vcs="%(3V:$(prompt_pdp-vcs_hl vcsbranch '<%4v>'):)"
PS1="$prefix$level$error$jobc$name@$host$employer:$line$time$vcs$cmdc$pathdisp%# "
PS2='%(4_:... :)%3_> '
RPS1="%(3V:$(prompt_pdp-vcs_hl vcstype '(%3v)'):)"
psvar=()
function precmd { prompt_pdp-vcs_precmd }
function preexec { }
}
prompt_pdp-vcs_setup "$@"
----------------------------8< cut here >8------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Submitting vcs_info function
2008-09-21 9:39 ` Phil Pennock
@ 2008-09-21 10:00 ` Phil Pennock
0 siblings, 0 replies; 10+ messages in thread
From: Phil Pennock @ 2008-09-21 10:00 UTC (permalink / raw)
To: zsh-workers
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@SPODHUIS.ORG $
+# $Id: prompt_pdp-vcs_setup 240 2008-09-21 09:52:38Z xxx@SPODHUIS.ORG $
#
# 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------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Submitting vcs_info function
2008-09-21 9:11 ` Clint Adams
2008-09-21 9:39 ` Phil Pennock
@ 2008-09-21 10:23 ` Frank Terbeck
2008-09-22 17:17 ` Clint Adams
1 sibling, 1 reply; 10+ messages in thread
From: Frank Terbeck @ 2008-09-21 10:23 UTC (permalink / raw)
To: zsh-workers
Clint Adams <clint@zsh.org>:
> On Wed, Sep 17, 2008 at 10:32:42PM +0200, Frank Terbeck wrote:
> > +If you plan to use the information from var(vcs_info) in your prompt (which
> > +is its primary use), you need to enable the tt(PROMPT_SUBST) option.
>
> I don't think that this claim is accurate.
Hm, true. How about 'Unless you dynamically build your prompt in
precmd(), you will need PROMPT_SUBST enabled.'?
Or: 'Depending on the way you are building your prompt you may need
PROMPT_SUBST enabled.'
Or something completely different (like dropping that sentence
altogether)?
Regards, Frank
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Submitting vcs_info function
2008-09-21 10:23 ` Frank Terbeck
@ 2008-09-22 17:17 ` Clint Adams
0 siblings, 0 replies; 10+ messages in thread
From: Clint Adams @ 2008-09-22 17:17 UTC (permalink / raw)
To: zsh-workers
On Sun, Sep 21, 2008 at 12:23:06PM +0200, Frank Terbeck wrote:
> Or something completely different (like dropping that sentence
> altogether)?
I like that one.
Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.87
diff -u -r1.87 contrib.yo
--- Doc/Zsh/contrib.yo 22 Sep 2008 16:57:49 -0000 1.87
+++ Doc/Zsh/contrib.yo 22 Sep 2008 17:16:06 -0000
@@ -347,9 +347,6 @@
example(autoload -Uz vcs_info)
-If you plan to use the information from var(vcs_info) in your prompt (which
-is its primary use), you need to enable the tt(PROMPT_SUBST) option.
-
It can be used in any existing prompt, because it does not require any
tt($psvar) entries to be left available.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Submitting vcs_info function
[not found] <20080917201859.GU2182@fsst.voodoo.lan>
[not found] ` <20080918112003.45911104@news01>
[not found] ` <20080917203242.GV2182@fsst.voodoo.lan>
@ 2008-09-21 19:57 ` Clint Adams
2008-09-21 20:32 ` Frank Terbeck
2 siblings, 1 reply; 10+ messages in thread
From: Clint Adams @ 2008-09-21 19:57 UTC (permalink / raw)
To: zsh workers; +Cc: subversion, bzr
On Wed, Sep 17, 2008 at 10:18:59PM +0200, Frank Terbeck wrote:
> I've been working on this for quite some time now. vcs_info is a
> function that is able to get information about directories under
> version control. That information can be used in prompts, for example.
Some initial feedback is that performancewise git is great,
svn has mixed reactions, and bzr is slow as a dog, even with use-simple
on.
Maybe someone can suggest some optimizations.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Submitting vcs_info function
2008-09-21 19:57 ` Clint Adams
@ 2008-09-21 20:32 ` Frank Terbeck
2008-09-22 6:42 ` Clint Adams
0 siblings, 1 reply; 10+ messages in thread
From: Frank Terbeck @ 2008-09-21 20:32 UTC (permalink / raw)
To: zsh workers; +Cc: bzr
Clint Adams <schizo@debian.org>:
> [...]bzr is slow as a dog, even with use-simple on.
The normal bzr backend *is* slow. It calls bzr itself twice. Which
takes about half a second on my system, at best. Agonising.
But the use-simple backend really only reads from *one* file. That
should work instantaneous, unless you're on a networked filesystem.
Are the people complaining _sure_ they enabled use-simple correctly?
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20080917201859.GU2182__38438.7229955339$1221682908$gmane$org@fsst.voodoo.lan>]
end of thread, other threads:[~2008-09-22 17:17 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20080917201859.GU2182@fsst.voodoo.lan>
[not found] ` <20080918112003.45911104@news01>
[not found] ` <20080918165212.GY2182@fsst.voodoo.lan>
[not found] ` <200809181700.m8IH0rmj019423@news01.csr.com>
[not found] ` <20080919093449.GI2182@fsst.voodoo.lan>
[not found] ` <20080919140229.3c4e9fcd@news01>
[not found] ` <20080919133411.GN2182@fsst.voodoo.lan>
2008-09-19 14:57 ` Submitting vcs_info function Frank Terbeck
[not found] ` <20080917203242.GV2182@fsst.voodoo.lan>
2008-09-21 9:11 ` Clint Adams
2008-09-21 9:39 ` Phil Pennock
2008-09-21 10:00 ` Phil Pennock
2008-09-21 10:23 ` Frank Terbeck
2008-09-22 17:17 ` Clint Adams
2008-09-21 19:57 ` Clint Adams
2008-09-21 20:32 ` Frank Terbeck
2008-09-22 6:42 ` Clint Adams
[not found] <20080917201859.GU2182__38438.7229955339$1221682908$gmane$org@fsst.voodoo.lan>
2008-09-17 23:05 ` Michael Prokop
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).