From owner-freebsd-questions@FreeBSD.ORG Wed May 17 09:10:12 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 530E416A44D for ; Wed, 17 May 2006 09:10:12 +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 C4A6043D5F for ; Wed, 17 May 2006 09:10:11 +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 <0IZE007LDK4WOI70@osl1smout1.broadpark.no> for questions@freebsd.org; Wed, 17 May 2006 11:10:08 +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 <0IZE00GTTK4VJE90@osl1sminn1.broadpark.no> for questions@freebsd.org; Wed, 17 May 2006 11:10:08 +0200 (CEST) Date: Wed, 17 May 2006 11:10:07 +0200 From: Kyrre Nygard In-reply-to: <20060516163920.GB9679@holestein.holy.cow> To: Parv Message-id: <7.0.1.0.2.20060517110543.021ea8d8@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> Cc: questions@freebsd.org 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 09:10:12 -0000 At 18:39 16.05.2006, Parv wrote: >in message <7.0.1.0.2.20060516102254.021e2b50@broadpark.no>, >wrote Kyrre Nygard thusly... > > > > > > This one, with a real nice color setting: > > > > (kyrre@merhaba)(09:58+16/05) > > (%:~) > > > > Requires all this: > > > > 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 > > > > I was wondering, were I to convert to bash, how would it then look like? > >All you need to do is replace zsh provided format strings to that of >similar bash escape sequences. For example, zsh '%n' (for >username) corresponds to bash '\u', '%~' to '\w', and so on. > >I personally put the color, bold, normal, etc. sequences in a >separate file, which is sourced inside the file setting prompt. >That gives less of gobbledygook to parse. For zsh, i have somewhere >in ~/.zshrc ... > > # http://www103.pair.com/parv/comp/unix/cf/sh/var/colors > . ~/cf/sh/var/colors > > case $TERM in > *xterm* | *rxvt* ) > PS1="# ?:%? %j %l ${bold}${yellow_fg}%~${normal}${normal}" > PS1="$PS1 %n.${bold}${cyan_fg}%m${normal}${normal}" > PS1=" > $PS1 (%D{%a %b%d %I%M}) > #! " > export PS1 > ;; > > * ) > PS1="# %j %n@%m %l ${bold}%3~${normal} > # " > export PS1 > ;; > esac > > >... similar thing is done for bash prompt. > > > - Parv > >-- Hey Parv! This sounds truly fabulous man, I guess there's no need for me to switch to bash after all :) But like in the case of: local Normal="[0m" What's with that weird character? Thanks! Kyrre