From owner-freebsd-questions@FreeBSD.ORG Wed May 17 15:04:45 2006 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E436C16AA70 for ; Wed, 17 May 2006 15:04:45 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id D632143D4C for ; Wed, 17 May 2006 15:04:44 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.4) id k4HF4c1K083670; Wed, 17 May 2006 10:04:38 -0500 (CDT) (envelope-from dan) Date: Wed, 17 May 2006 10:04:38 -0500 From: Dan Nelson To: Kyrre Nygard Message-ID: <20060517150438.GA96480@dan.emsphone.com> References: <7.0.1.0.2.20060516102254.021e2b50@broadpark.no> <20060516163920.GB9679@holestein.holy.cow> <7.0.1.0.2.20060517112311.021f9220@broadpark.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7.0.1.0.2.20060517112311.021f9220@broadpark.no> X-OS: FreeBSD 5.5-PRERELEASE X-message-flag: Outlook Error User-Agent: Mutt/1.5.11 Cc: questions@freebsd.org, Parv Subject: Re: Converting a zsh prompt to bash X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 May 2006 15:04:59 -0000 In the last episode (May 17), Kyrre Nygard said: > Do you think this would work? > > I tried applying your principles, as well as some information design: > > local a1="01;36m" > local a2="22;36m" > local a3="01;30m" > > local b1="01;31m" > local b2="22;31m" > local b3="01;30m" > > PROMPT=$'%{$a1}(%{$a2}%n%{$a3}@%{$a2}%m%{$a1})' > PROMPT+=$'%{$a1}('{$a2}%D{%H:%M}%{$a3}+%{$a2}%D{%d/%m}%{$a1})%{$a3}\n' > PROMPT+=$'%{$a1}(%{$a2}%#%{$a3}:%{$a2}%~%{$a1})' > > if [[ `whoami` = root ]] then > PROMPT=$'%{$b1}(%{$b2}%n%{$b3}@%{$b2}%m%{$b1})' > PROMPT+=$'%{$b1}(%{$b2}%D{%H:%M}%{$b3}+%{$b2}%D{%d/%m}%{$b1})%{$b3}\n' > PROMPT+=$'%{$b1}(%{$b2}%#%{$b3}:%{$b2}%~%{$b1})' > fi Note that zsh provides symbolic variables for color setting: autoload -U colors colors echo "$fg[blue]$bg[red]blue on red!" so you don't have to memorize the numbers. See the zshcontrib manpage, "OTHER FUNCTIONS" section. If the only difference between your root prompt is color, you can also just set a1,a2,a3 to different values within your if block, then set PROMPT outside of it. if [[ $USER == root ]] ; then a1="%{$fg[cyan]$bg[black]}" else a1="%{$fg[red]}$bg[black]}" fi PROMPT="$a1>" -- Dan Nelson dnelson@allantgroup.com