Date: Thu, 18 May 2006 19:30:28 +0200 From: Kyrre Nygard <kyrreny@broadpark.no> To: Dan Nelson <dnelson@allantgroup.com> Cc: questions@freebsd.org, Parv <parv@pair.com> Subject: Re: Converting a zsh prompt to bash Message-ID: <7.0.1.0.2.20060518192702.022713f0@broadpark.no> In-Reply-To: <20060518150254.GA61792@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> <20060517150438.GA96480@dan.emsphone.com> <7.0.1.0.2.20060518105022.022051b8@broadpark.no> <20060518150254.GA61792@dan.emsphone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
At 17:02 18.05.2006, Dan Nelson wrote: >In the last episode (May 18), Kyrre Nygard said: > > 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>" > > > > Hey Dan! > > > > I can't find a list of what colors are available. Besides I doubt > > that mine are accounted for. > >There are only so many ways to combine 8 colors :) From the manpage: > > colors This function initializes several associative arrays to map > color names to (and from) the ANSI standard eight-color terminal > codes. These are used by the prompt theme system (see above). > You seldom should need to run colors more than once. > > The eight base colors are: black, red, green, yellow, blue, > magenta, cyan, and white. Each of these has codes for fore- > ground and background. In addition there are eight intensity > attributes: bold, faint, standout, underline, blink, reverse, > and conceal. Finally, there are six codes used to negate > attributes: none (reset all attributes to the defaults), normal > (neither bold nor faint), no-standout, no-underline, no-blink, > and no-reverse. > > > 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%} ' > >How about something like: > >autoload -U colors >colors > >if [[ $USER == root ]] ; then > c1="%{$fg_no_bold[cyan]%}" # base color1 > c2="%{$fg_bold[cyan]%}" # base color2 > c3="%{$fg_bold[black]%}" # punctuation >else > c1="%{$fg_no_bold[red]%}" # base color1 > c2="%{$fg_bold[red]%}" # base color2 > c3="%{$fg_bold[black]%}" # punctuation >fi > >PROMPT="$c2($c1%n$c3@$c1%m$c2)($c1%D{%H:%M}$c3+$c1%D{%d/%m}$c2)"$'\n' >PROMPT+="$c2($c1%#$c3:$c1%~$c2) %{$reset_color%}" > >-- > Dan Nelson > dnelson@allantgroup.com Oh man! That is absolutely gorgeous!!! Thank you so much :))) My /etc/zshrc is now worth $10.000 (up from $7.000) Don't sell it on eBay you all: http://paste.husk.org/5717 Just out of curiosity Dan, how does your prompt look like? All the best, Kyrre
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7.0.1.0.2.20060518192702.022713f0>