Date: Wed, 17 May 2006 11:26:51 +0200 From: Kyrre Nygard <kyrreny@broadpark.no> To: Parv <parv@pair.com> Cc: questions@freebsd.org Subject: Re: Converting a zsh prompt to bash Message-ID: <7.0.1.0.2.20060517112311.021f9220@broadpark.no> In-Reply-To: <20060516163920.GB9679@holestein.holy.cow> References: <7.0.1.0.2.20060516102254.021e2b50@broadpark.no> <20060516163920.GB9679@holestein.holy.cow>
next in thread | previous in thread | raw e-mail | index | archive | help
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 > >-- Hello again man! 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}%{$b1}(%{$b2}%D{%H:%M}%{$b3}+%{$b2}%D{%d/%m}%{$b1})%{$b3}\n' PROMPT+=$'%{$b1}(%{$b2}%#%{$b3}:%{$b2}%~%{$b1})' fi I would appreciate your green light before I test this :) Thanks again, Kyrre
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7.0.1.0.2.20060517112311.021f9220>