Re: Converting a zsh prompt to bash
At 22:48 18.05.2006, Dan Nelson wrote: In the last episode (May 18), Kyrre Nygard said: 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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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([EMAIL PROTECTED])($c1%D{%H:%M}$c3+$c1%D{%d/%m}$c2)$'\n' PROMPT+=$c2($c1%#$c3:$c1%~$c2) %{$reset_color%} -- Dan Nelson [EMAIL PROTECTED] 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? Mine's strictly functional. User, host, path in left prompt; error status in right prompt. Within screen, I add the window number to the left prompt and the datetime to the right prompt so I know how long I've left a window idle. if [[ $+WINDOW = 1 $TERM = screen* ]] ; then PROMPT=([EMAIL PROTECTED]) %B%/%(#/#/)%b RPROMPT=%(?.. %B%?%b)%t %D{%m/%d} else PROMPT=([EMAIL PROTECTED]) %B%/%(#/#/)%b RPROMPT=%(?..%?) fi -- Dan Nelson [EMAIL PROTECTED] Hey Dan! Your prompt is truly wonderful. It inspired me to grow up, as far as my shell is concerned. Based on your design, I came up with this: if [[ `whoami` = root ]] then a1=%{$fg_bold[red]%} a2=%{$fg_no_bold[red]%} else a1=%{$fg_bold[cyan]%} a2=%{$fg_no_bold[cyan]%} fi if [[ $+WINDOW = 1 $TERM = screen* ]] then PROMPT=$a1([EMAIL PROTECTED]) [$WINDOW] $a2%~ %{$reset_color%} RPROMPT=%D{%H:%M} %D{%d/%m} fi PROMPT=$a1([EMAIL PROTECTED]) $a2%~ %{$reset_color%} RPROMPT=%D{%H:%M} %D{%d/%m} And I think I'm keeping it like that. Unless you have any suggestions on how to simply its setup? It takes up a lot of lines, maybe it could shrink a little. I hope you don't consider me stealing your design. If that's the case I'll revert back to my old one. It's kinda nice though,
Re: Converting a zsh prompt to bash
At 22:48 18.05.2006, Dan Nelson wrote: Mine's strictly functional. User, host, path in left prompt; error status in right prompt. Within screen, I add the window number to the left prompt and the datetime to the right prompt so I know how long I've left a window idle. if [[ $+WINDOW = 1 $TERM = screen* ]] ; then PROMPT=([EMAIL PROTECTED]) %B%/%(#/#/)%b RPROMPT=%(?.. %B%?%b)%t %D{%m/%d} else PROMPT=([EMAIL PROTECTED]) %B%/%(#/#/)%b RPROMPT=%(?..%?) fi -- Dan Nelson [EMAIL PROTECTED] This is what I'm now going to settle with. The screen function was really wicked. I've always felt lost while I'm messing about my screens. If you have any advice, please make them regarding this setup: if [[ `whoami` = root ]] then a1=%{$fg_bold[red]%} a2=%{$fg_no_bold[red]%} else a1=%{$fg_bold[cyan]%} a2=%{$fg_no_bold[cyan]%} fi PROMPT=$a1([EMAIL PROTECTED])$a2(%D{%d/%m}+%D{%H:%M})$'\n' PROMPT+=$a2(%~) %{$reset_color%} if [[ $+WINDOW = 1 $TERM = screen* ]] then PROMPT=$a1([EMAIL PROTECTED])$a2($WINDOW)(%D{%d/%m}+%D{%H:%M})$'\n' PROMPT+=$a2(%~) %{$reset_color%} fi Thanks :) Kyrre ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
Hey Dan! Your prompt is truly wonderful. It inspired me to grow up, as far as my shell is concerned. hmm - no: grownups use tput rather than hardcoding things. -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net pgpaAKCgMiHgm.pgp Description: PGP signature
Re: Converting a zsh prompt to bash
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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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 [EMAIL PROTECTED] 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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED]) 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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([EMAIL PROTECTED])($c1%D{%H:%M}$c3+$c1%D{%d/%m}$c2)$'\n' PROMPT+=$c2($c1%#$c3:$c1%~$c2) %{$reset_color%} -- Dan Nelson [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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([EMAIL PROTECTED])($c1%D{%H:%M}$c3+$c1%D{%d/%m}$c2)$'\n' PROMPT+=$c2($c1%#$c3:$c1%~$c2) %{$reset_color%} -- Dan Nelson [EMAIL PROTECTED] 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
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? post a screenshot somewhere =) sounds like you like your new prompt quite a bit =) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
At 19:50 18.05.2006, Eric wrote: 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? post a screenshot somewhere =) sounds like you like your new prompt quite a bit =) The prompt is the same however the way of writing it into the zshrc is now, thanks to Mr. Dan Nelson, much better. Why a screenshot? There's no virus in it. Give it a go :) And the best of luck to you, -- Kyrre ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
In the last episode (May 18), Kyrre Nygard said: 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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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([EMAIL PROTECTED])($c1%D{%H:%M}$c3+$c1%D{%d/%m}$c2)$'\n' PROMPT+=$c2($c1%#$c3:$c1%~$c2) %{$reset_color%} -- Dan Nelson [EMAIL PROTECTED] 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? Mine's strictly functional. User, host, path in left prompt; error status in right prompt. Within screen, I add the window number to the left prompt and the datetime to the right prompt so I know how long I've left a window idle. if [[ $+WINDOW = 1 $TERM = screen* ]] ; then PROMPT=([EMAIL PROTECTED]) %B%/%(#/#/)%b RPROMPT=%(?.. %B%?%b)%t %D{%m/%d} else PROMPT=([EMAIL PROTECTED]) %B%/%(#/#/)%b RPROMPT=%(?..%?) fi -- Dan Nelson [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
At 18:39 16.05.2006, Parv wrote: in message [EMAIL PROTECTED], wrote Kyrre Nygard thusly... This one, with a real nice color setting: ([EMAIL PROTECTED])(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 [EMAIL PROTECTED] %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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
At 18:39 16.05.2006, Parv wrote: in message [EMAIL PROTECTED], wrote Kyrre Nygard thusly... This one, with a real nice color setting: ([EMAIL PROTECTED])(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 [EMAIL PROTECTED] %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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
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}([EMAIL PROTECTED])' 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}([EMAIL PROTECTED])' 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 [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Converting a zsh prompt to bash
Hello! I have a real nice prompt in zsh however I feel its setting in /etc/zshrc might be a bit too much to just specify a prompt. This one, with a real nice color setting: ([EMAIL PROTECTED])(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 suggestions welcome, Kyrre ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Converting a zsh prompt to bash
in message [EMAIL PROTECTED], wrote Kyrre Nygard thusly... This one, with a real nice color setting: ([EMAIL PROTECTED])(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 [EMAIL PROTECTED] %l ${bold}%3~${normal} # export PS1 ;; esac ... similar thing is done for bash prompt. - Parv -- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]