From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4496 invoked from network); 16 Feb 2008 07:56:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 16 Feb 2008 07:56:44 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 18268 invoked from network); 16 Feb 2008 07:56:39 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Feb 2008 07:56:39 -0000 Received: (qmail 27972 invoked by alias); 16 Feb 2008 07:56:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24557 Received: (qmail 27956 invoked from network); 16 Feb 2008 07:56:36 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 16 Feb 2008 07:56:36 -0000 Received: from flock1.newmail.ru (flock1.newmail.ru [82.204.219.207]) by bifrost.dotsrc.org (Postfix) with SMTP id 325858026E0B for ; Sat, 16 Feb 2008 08:56:31 +0100 (CET) Received: (qmail 14642 invoked from network); 16 Feb 2008 07:56:30 -0000 Received: from unknown (HELO cooker.net) (arvidjaar@newmail.ru@91.77.239.52) by smtpd.newmail.ru with SMTP; 16 Feb 2008 07:56:30 -0000 From: Andrey Borzenkov To: zsh-workers@sunsite.dk Subject: Re: Fw: Phil's prompt is not working when LANG is set to UTF-8 Date: Sat, 16 Feb 2008 10:56:25 +0300 User-Agent: KMail/1.9.9 References: <20080215235241.2f255730@pws-pc> In-Reply-To: <20080215235241.2f255730@pws-pc> Cc: Wael Nasreddine MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3196638.ScjtcfhFU6"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200802161056.29466.arvidjaar@newmail.ru> X-Virus-Scanned: ClamAV version 0.91.2, clamav-milter version 0.91.2 on bifrost X-Virus-Status: Clean --nextPart3196638.ScjtcfhFU6 Content-Type: multipart/mixed; boundary="Boundary-01=_pcptHEpayi8jx1H" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_pcptHEpayi8jx1H Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Saturday 16 February 2008, Peter Stephenson wrote: > How about the following tweak to prompts to support this? The upshot is > that you include any funny characters in %{...%G%} where the %G for > `glitch' (which may be repeated or take a numeric argument) indicates a > screen cell taken up by the sequence.=20 Yes, I was about to try the same today morning (you have to sleep on it); but I likely would not end up with such elegant solution. > I like this because it uses=20 > facilities that have been present in the shell for a long time and hence > was trivial to implement and might work. >=20 > I played with this in simple cases, but would anybody like to confirm > this works in the cases that matter (and maybe produce an updated Phil's > Prompt)?=20 I confirm that this works and updated prompt is attached. Wael, does it work for you with this patch applied? Now downside of course is, it works only with patched shell ... > To put it another way: I am happy to support this fix but=20 > have no interest in doing anything with it myself. >=20 > I think this is clean and useful enough that I will commit it anyway. --Boundary-01=_pcptHEpayi8jx1H Content-Type: text/plain; charset="iso-8859-1"; name="phils.new" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="phils.new" # vim:ft=zsh:fenc=UTF-8:ts=4:sts=4:sw=4:expandtab: # $Id$ function precmd { local TERMWIDTH (( TERMWIDTH = ${COLUMNS} - 1 )) ### # Truncate the path if it's too long. PR_FILLBAR="" PR_FILLBAR_PRE="" PR_FILLBAR_POST="" PR_PWDLEN="" local promptsize=${#${(%):---(%n@%m:%l)---()--}} local pwdsize=${#${(%):-%~}} if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then ((PR_PWDLEN=$TERMWIDTH - $promptsize)) else PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR_PURE}.)}" PR_FILLBAR_PRE="%{" PR_FILLBAR_POST="%${#PR_FILLBAR}G%}" fi ### # Get APM info. # if which ibam &> /dev/null; then # PR_APM_RESULT=`ibam --percentbattery 2> /dev/null` # elif which apm &> /dev/null; then # PR_APM_RESULT=`apm 2> /dev/null` # fi } setopt extended_glob preexec () { if [[ "$TERM" == "screen" ]]; then local CMD=${1[(wr)^(*=*|sudo|-*)]} echo -n "\ek$CMD\e\\" fi } setprompt () { ### # Need this so the prompt will work. setopt prompt_subst ### # See if we can use colors. autoload colors zsh/terminfo if [[ "$terminfo[colors]" -ge 8 ]]; then colors fi for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' (( count = $count + 1 )) done PR_NO_COLOUR="%{$terminfo[sgr0]%}" ### # See if we can use extended characters to look nicer. typeset -A altchar set -A altchar ${(s..)terminfo[acsc]} PR_SET_CHARSET="%{$terminfo[enacs]%}" PR_SHIFT_IN="%{$terminfo[smacs]%}" PR_SHIFT_OUT="%{$terminfo[rmacs]%}" PR_HBAR_PURE="${altchar[q]:--}" PR_HBAR="%{${altchar[q]:--}%G%}" PR_ULCORNER="%{${altchar[l]:--}%G%}" PR_LLCORNER="%{${altchar[m]:--}%G%}" PR_LRCORNER="%{${altchar[j]:--}%G%}" PR_URCORNER="%{${altchar[k]:--}%G%}" ### # Decide if we need to set titlebar text. case $TERM in xterm*) PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}' ;; screen*) PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}' ;; *) PR_TITLEBAR='' ;; esac ### # Decide whether to set a screen title if echo "${TERM}" | grep -q "^screen"; then PR_STITLE=$'%{\ekzsh\e\\%}' else PR_STITLE='' fi ### # APM detection # if which ibam > /dev/null; then # PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:' # elif which apm > /dev/null; then # PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:' # else # PR_APM='' # fi ### # Finally, the prompt. PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ $PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\ $PR_CYAN%(!.%SROOT%s.%n)$PR_YELLOW@$PR_GREEN%m$PR_YELLOW:$PR_BLUE%l\ $PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR$PR_FILLBAR_PRE${(e)PR_FILLBAR}$PR_FILLBAR_POST$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\ $PR_MAGENTA%$PR_PWDLEN<...<%~%<<\ $PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_URCORNER$PR_SHIFT_OUT\ $PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\ %(?..$PR_LIGHT_RED%?$PR_BLUE:)\ ${(e)PR_APM}$PR_YELLOW%D{%H:%M}\ $PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_NO_COLOUR ' RPROMPT=' $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\ ($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR' PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\ $PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR ' } setprompt print -rnP -- "$PROMPT" > /tmp/PROMPT print -rnP -- "$RPROMPT" > /tmp/RPROMPT --Boundary-01=_pcptHEpayi8jx1H-- --nextPart3196638.ScjtcfhFU6 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (GNU/Linux) iEYEABECAAYFAke2lykACgkQR6LMutpd94xdMgCgltBm16nWaDQ/3GMQrhik013v rtIAoJT/cX7scDxWHZb1qnJFHRyBrwWm =jVmu -----END PGP SIGNATURE----- --nextPart3196638.ScjtcfhFU6--