From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9869 invoked from network); 17 Jun 2004 12:27:07 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 17 Jun 2004 12:27:07 -0000 Received: (qmail 5413 invoked from network); 17 Jun 2004 12:26:27 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Jun 2004 12:26:27 -0000 Received: (qmail 5588 invoked by alias); 17 Jun 2004 12:26:00 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7555 Received: (qmail 5578 invoked from network); 17 Jun 2004 12:25:59 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 17 Jun 2004 12:25:56 -0000 Received: (qmail 3551 invoked from network); 17 Jun 2004 12:25:56 -0000 Received: from vinc17.net1.nerim.net (HELO ay.vinc17.org) (62.4.18.82) by a.mx.sunsite.dk with SMTP; 17 Jun 2004 12:25:54 -0000 Received: from lefevre by ay.vinc17.org with local (Exim 4.32) id 1BavxP-0004qD-Gs; Thu, 17 Jun 2004 14:25:27 +0200 Date: Thu, 17 Jun 2004 14:25:27 +0200 From: Vincent Lefevre To: ZSH-users Subject: Re: Coolest prompt? Message-ID: <20040617122527.GF12350@ay.vinc17.org> Mail-Followup-To: ZSH-users References: <200406111329.45312.myrmidon@vfemail.net> <87CE3664-BBF7-11D8-9BE4-000393ABF2F0@chemistry.ucsc.edu> <20040615151840.GC7673@cvmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040615151840.GC7673@cvmx.de> X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.6i Sender: Vincent Lefevre X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On 2004-06-15 17:18:40 +0200, Julius Plenz wrote: > To see this Prompt in action, look at this example: > > e/www/plenz,0% cd www/ > w/plenz/www,0% cd plenz.com/ > w/plenz.com,0% cd /tmp > /tmp,0% sleep 10& > [1] 16056 > /tmp,1% cd > [1] + 16056 done sleep 10 > e/www/plenz,0% > > So, you see, there is a fixed path-length and the number of > background jobs. I really like this prompt, its simple but gives > enough information. You could avoid to write ",0" when there are no background jobs. Here's my prompt code: setopt PROMPT_SUBST setopt PROMPT_PERCENT zmodload -i zsh/parameter precmd() { local njobs if [[ $domain == local.ay && "$(pmu_battery)" == "Battery" ]] then psvar[1]="[$(pmu_percent)%]" else psvar[1]="" fi njobs=$#jobstates; case $njobs in 0) psvar[2]=();; 1) psvar[2]="1 job";; *) psvar[2]="$njobs jobs";; esac [[ -n $TTY && $TERM == (xterm*|dtterm|rxvt|screen*) ]] && { print -nP "\e]1;%m:%.\x07" print -nP "\e]2;%(2v. %2v |.)${WINTITLE:+ $WINTITLE |} %n@%m - %~ | %y" [[ $TERM == screen* ]] && print -n . print -n "\x07" } > $TTY } TRAPCLD() { [[ -o interactive && -n $TTY ]] && precmd } putprompt() { local preprompt postprompt prefail postfail if [[ -n $COLORTERM ]] then local bgcol=`tput setab 0` preprompt="%{`tput bold`$bgcol%(2v.`tput setaf 2`.`tput setaf 3`)%}" postprompt="%{`tput sgr0`%}" prefail="%{`tput setab 1`%}" postfail="%{$bgcol%}" fi PS1="%m:%20<...<%~%<<%(?..${prefail}[%?]${postfail})%1v%(#.#.>) " RPS1="<%*" PS1="$preprompt$PS1$postprompt" RPS1="$preprompt$RPS1$postprompt" PS2="$preprompt$PS2$postprompt" PS3="$preprompt$PS3$postprompt" PS4="$preprompt$PS4$postprompt" } putprompt -- Vincent Lefèvre - Web: 100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17, Championnat International des Jeux Mathématiques et Logiques, etc. Work: CR INRIA - computer arithmetic / SPACES project at LORIA