From owner-freebsd-questions@FreeBSD.ORG Thu May 18 09:00:01 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 A4D5116A416 for ; Thu, 18 May 2006 09:00:01 +0000 (UTC) (envelope-from kyrreny@broadpark.no) Received: from osl1smout1.broadpark.no (osl1smout1.broadpark.no [80.202.4.58]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1B38543D46 for ; Thu, 18 May 2006 09:00:01 +0000 (GMT) (envelope-from kyrreny@broadpark.no) Received: from osl1sminn1.broadpark.no ([80.202.4.59]) by osl1smout1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IZG004U4EBZ18E0@osl1smout1.broadpark.no> for questions@freebsd.org; Thu, 18 May 2006 10:59:59 +0200 (CEST) Received: from urban.broadpark.no ([80.203.212.30]) by osl1sminn1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IZG00DF8EBZUCC0@osl1sminn1.broadpark.no> for questions@freebsd.org; Thu, 18 May 2006 10:59:59 +0200 (CEST) Date: Thu, 18 May 2006 11:00:00 +0200 From: Kyrre Nygard In-reply-to: <20060517150438.GA96480@dan.emsphone.com> To: Dan Nelson Message-id: <7.0.1.0.2.20060518105022.022051b8@broadpark.no> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <7.0.1.0.2.20060516102254.021e2b50@broadpark.no> <20060516163920.GB9679@holestein.holy.cow> <7.0.1.0.2.20060517112311.021f9220@broadpark.no> <20060517150438.GA96480@dan.emsphone.com> 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: Thu, 18 May 2006 09:00:01 -0000 At 17:04 17.05.2006, Dan Nelson wrote: >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 Hey Dan! I can't find a list of what colors are available. Besides I doubt that mine are accounted for. I'd be very grateful if you could at least try this prompt out so you know my request: PROMPT=$'%{\e[01;36m%}(%{\e[22;36m%}%n%{\e[01;30m%}@' PROMPT+=$'%{\e[22;36m%}%m%{\e[01;36m%})%{\e[01;36m%}%{\e[01;36m%}(' PROMPT+=$'%{\e[22;36m%}%D{%H:%M}%{\e[01;30m%}+%{\e[22;36m%}%D{%d/%m}' PROMPT+=$'%{\e[01;36m%})%{\e[01;30m\e[00m%}\n%{\e[01;36m%}(' PROMPT+=$'%{\e[22;36m%}%#%{\e[01;30m%}:%{\e[22;36m%}%~%{\e[01;36m%})' PROMPT+=$'%{\e[01;30m\e[00m%} ' if [[ `whoami` = root ]] then PROMPT=$'%{\e[01;31m%}(%{\e[22;31m%}%n%{\e[01;30m%}@' PROMPT+=$'%{\e[22;31m%}%m%{\e[01;31m%})%{\e[01;31m%}%{\e[01;31m%}(' PROMPT+=$'%{\e[22;31m%}%D{%H:%M}%{\e[01;30m%}+%{\e[22;31m%}%D{%d/%m}' PROMPT+=$'%{\e[01;31m%})%{\e[01;30m\e[00m%}\n%{\e[01;31m%}(' PROMPT+=$'%{\e[22;31m%}%#%{\e[01;30m%}:%{\e[22;31m%}%~%{\e[01;31m%})' PROMPT+=$'%{\e[01;30m\e[00m%} ' fi Anyway I just went ahead and tested this: 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}%{$b1}(%{$b2}%D{%H:%M}%{$b3}+%{$b2}%D{%d/%m}%{$b1})%{$b3}\n' PROMPT+=$'%{$b1}(%{$b2}%#%{$b3}:%{$b2}%~%{$b1})' fi But I got: /etc/zshrc:32: parse error near `)' $a1}($a2}root$a3}@$a2}ninja$a1}) The: > if [[ $USER == root ]] ; then > a1="%{$fg[cyan]$bg[black]}" > else > a1="%{$fg[red]}$bg[black]}" > fi > PROMPT="$a1>" Technique sounds very interesting, but it's getting a bit too advanced for my part. Take care man, and thanks again! All the best, Kyrre