zsh-users
 help / color / mirror / code / Atom feed
* "converting"
@ 2002-01-24  6:49 Joakim Ryden
  2002-01-24  7:00 ` "converting" Will Yardley
  2002-01-24 10:31 ` "converting" Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Joakim Ryden @ 2002-01-24  6:49 UTC (permalink / raw)
  To: Zsh-users List

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

hi - 

i found a neat looking prompt written for bash that i'd like to use with
zsh. the whole thing looks like:


CW="\[\033[0;1;37m\]"   #Color for [ and ]
CB="\[\033[0;1;34m\]"   #Color for label
CR="\[\033[0;1;33m\]"   #Color for value
NC="\[\033[0m\]"        #No Color
MT="\[\033[0;0f\]"      #Move to the top
SP="\[\0337\]"          #Save Position
RP="\[\0338\]"          #Restore Position
CL="\[\033[K\]"         #Clear Line

TOPBAR="$SP$MT$CL$CR User: $CB\u$NC$CR  Host: $CB\h$NC$CR Time:
$CB\t$NC$RP"
PS1="\n$CW[$CB\w$CW]$NC$TOPBAR"

i'm not really sure at all where to start with this, the only thing i
would really know how to do is "translate" the "\u,\h,\w" to something
zsh understands. can someone point me to a good place for starting to
"convert" this?

Thanks!

Jo

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "converting"
  2002-01-24  6:49 "converting" Joakim Ryden
@ 2002-01-24  7:00 ` Will Yardley
  2002-01-24  7:17   ` "converting" Joakim Ryden
  2002-01-24 10:31 ` "converting" Peter Stephenson
  1 sibling, 1 reply; 6+ messages in thread
From: Will Yardley @ 2002-01-24  7:00 UTC (permalink / raw)
  To: Zsh-users List

Joakim Ryden wrote:
> 
> i found a neat looking prompt written for bash that i'd like to use with
> zsh. the whole thing looks like:
> 
> TOPBAR="$SP$MT$CL$CR User: $CB\u$NC$CR  Host: $CB\h$NC$CR Time:
> $CB\t$NC$RP"
> PS1="\n$CW[$CB\w$CW]$NC$TOPBAR"
> 
> i'm not really sure at all where to start with this, the only thing i
> would really know how to do is "translate" the "\u,\h,\w" to something
> zsh understands. can someone point me to a good place for starting to
> "convert" this?

hrmm perhaps TFM?  search for 'PROMPT EXPANSION' in the zshall man page.

       %n     $USERNAME.
       %M     The full machine hostname.
       %m     The  hostname  up to the first `.'.  An integer may
              follow the `%' to specify how  many  components  of
              the hostname are desired.  With a negative integer,
              trailing components of the hostname are shown.

as far as \w, zsh gives a lot of options for how to display the working
directory. i suggest reading the man page.

looking at other peoples' zshrc files can be very helpful as well.
check dotfiles.net, and do searches on google.

zsh is (IMHO) more flexible than bash as far as doing prompts.

also, you don't need to do as much fancy stuff to put stuff in the xterm
titlebar.

i have:

PS1="%B%m%b%# "

(hostname in bold, percent as a regular user, pound sign (#) as root) as
my prompt, and then:

case $TERM in
        rxvt|xterm*)
                precmd () {print -Pn "\e]2;%n@%m%#  %~ %l  %w :: %T\a"}
                preexec () {print -Pn "\e]2;%n@%m%#  <$1>  %~ %l  %w :: %T\a"}
        ;;
esac

(if i'm in rxvt or xterm put fancy crap in the titlebar).

w


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "converting"
  2002-01-24  7:00 ` "converting" Will Yardley
@ 2002-01-24  7:17   ` Joakim Ryden
  2002-01-24  7:44     ` "converting" Will Yardley
  0 siblings, 1 reply; 6+ messages in thread
From: Joakim Ryden @ 2002-01-24  7:17 UTC (permalink / raw)
  To: Will Yardley; +Cc: Zsh-users List

[-- Attachment #1: Type: text/plain, Size: 2255 bytes --]

On Wed, 2002-01-23 at 23:00, Will Yardley wrote:
> Joakim Ryden wrote:
> > 
> > i found a neat looking prompt written for bash that i'd like to use with
> > zsh. the whole thing looks like:
> > 
> > TOPBAR="$SP$MT$CL$CR User: $CB\u$NC$CR  Host: $CB\h$NC$CR Time:
> > $CB\t$NC$RP"
> > PS1="\n$CW[$CB\w$CW]$NC$TOPBAR"
> > 
> > i'm not really sure at all where to start with this, the only thing i
> > would really know how to do is "translate" the "\u,\h,\w" to something
> > zsh understands. can someone point me to a good place for starting to
> > "convert" this?
> 
> hrmm perhaps TFM?  search for 'PROMPT EXPANSION' in the zshall man page.
> 
>        %n     $USERNAME.
>        %M     The full machine hostname.
>        %m     The  hostname  up to the first `.'.  An integer may
>               follow the `%' to specify how  many  components  of
>               the hostname are desired.  With a negative integer,
>               trailing components of the hostname are shown.

right, i just said these were about the only things i knew how to
"translate" from the prompt above.

ok, let's try the question again... the problem with the above prompt
(assuming you change the \w etc to %~ or whatever) is this:

.zshrc:13: bad math expression: operand expected at `\[\033[0;1...'

i'm not sure whether this is because i have a certain combination of
setopt's or am lacking some setopt's[1] or the control codes need to be
expressed differently etc.

also, the prompt is neat but i'm not about to read TWFM to figure out
what i need to do to get it to work in zsh. :)

<SNIP>

> also, you don't need to do as much fancy stuff to put stuff in the xterm
> titlebar.

the above prompt doesn't put anything in the xterm titlebar. it keeps a
"floating" bar with username/host/time in the terminal window. fire up
bash and try it. ;)

--Jo

[1] these are the options i have set:

autocd
noautoparamslash
autopushd
autoresume
nobgnice
cdablevars
noclobber
correct
correctall
globdots
histignoredups
nohup
interactive
interactivecomments
login
longlistjobs
mailwarning
markdirs
monitor
printexitvalue
promptsubst
pushdminus
pushdsilent
pushdtohome
rcquotes
recexact
shinstdin
zle

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "converting"
  2002-01-24  7:17   ` "converting" Joakim Ryden
@ 2002-01-24  7:44     ` Will Yardley
  2002-01-24  7:52       ` "converting" Joakim Ryden
  0 siblings, 1 reply; 6+ messages in thread
From: Will Yardley @ 2002-01-24  7:44 UTC (permalink / raw)
  To: Zsh Users

Joakim Ryden wrote:
> 
> right, i just said these were about the only things i knew how to
> "translate" from the prompt above.

sorry - i misunderstood. i'm sure someone on the list will know better
(and i'll see if i can figure it out), but you might read the howto here
as well:

http://www-106.ibm.com/developerworks/linux/library/l-z.html?dwzone=linux

i'm pretty sure it's just a matter of quoting the escape codes correctly
for zsh.

looking through the examples of others is still a good idea since plenty
of people have similar things in their prompts.

i also think you should switch the $TOPBAR thing to going through precmd
- i think it will simplify your life a lot.

w


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "converting"
  2002-01-24  7:44     ` "converting" Will Yardley
@ 2002-01-24  7:52       ` Joakim Ryden
  0 siblings, 0 replies; 6+ messages in thread
From: Joakim Ryden @ 2002-01-24  7:52 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

On Wed, 2002-01-23 at 23:44, Will Yardley wrote:
> Joakim Ryden wrote:
> > 
> > right, i just said these were about the only things i knew how to
> > "translate" from the prompt above.
> 
> sorry - i misunderstood. i'm sure someone on the list will know better
> (and i'll see if i can figure it out), but you might read the howto here
> as well:
> 
> http://www-106.ibm.com/developerworks/linux/library/l-z.html?dwzone=linux

thanks will - i'll have a look and see what i can come up with (in
regards to using precmd as well).

--Jo

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: "converting"
  2002-01-24  6:49 "converting" Joakim Ryden
  2002-01-24  7:00 ` "converting" Will Yardley
@ 2002-01-24 10:31 ` Peter Stephenson
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2002-01-24 10:31 UTC (permalink / raw)
  To: Zsh users list

Joakim Ryden wrote:
> i found a neat looking prompt written for bash that i'd like to use with
> zsh. the whole thing looks like:

You might want to take a look at the prompt theme system supplied with 4.0
onward.  It's described in the zshcontrib manual page.  The functions live
in the Functions/Misc directory of the source code and are probably
installed somewhere under /usr/local/shar/zsh/<version>/functions.

If nothing there fits, you should be able to add your own prompt theme
along the lines of one of the existing ones, which could be added to the
distribution.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-01-24 10:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-24  6:49 "converting" Joakim Ryden
2002-01-24  7:00 ` "converting" Will Yardley
2002-01-24  7:17   ` "converting" Joakim Ryden
2002-01-24  7:44     ` "converting" Will Yardley
2002-01-24  7:52       ` "converting" Joakim Ryden
2002-01-24 10:31 ` "converting" Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).