a new zsh prompt

rjbs on 2006-03-28T05:03:30

I was looking into some zsh functionality today and decided it was time to update my prompt. Here's what I've come up with so far, with the help of jcap:

export PS1="%~$(print '%{\e[1m%}%(!.%{\e[31m%}#.%{\e[32m%}$)%{\e[0m%}') " export RPS1="%m@%D{%H%m%S}:%h"

This replaces my old prompt of:

export PS1='%m!%n:%~%(!.#.$) '

I liked the UUCP-style identifier, but the super-reduced left hand side is pretty slick, as is the one dot of color. (I tried using the built-in colors function, but it gave me grief.) I'd like to tidy up the RPS1, but I'm not sure how, yet.


builtin prompts

Dom2 on 2006-03-28T06:55:54

I use the builtin prompts that come with zsh. In particular, this setup works well for me:
autoload -U promptinit ; promptinit
prompt bart
-Dom

Re:builtin prompts

Simon on 2006-03-28T11:07:42

Oh, no, adam1 for me all the way. :) If you need the time and date, just drop this into your .screenrc: (You use screen, right?)
hardstatus alwayslastline "%-w%{.wB}%n %t%{-}%+w %=%{.w} %H: %l %{-}%d/%m %c"

Re:builtin prompts

Dom2 on 2006-03-28T11:53:37

I never leave home without screen. But that's very neat -- I like it!

-Dom

Re:builtin prompts

Aristotle on 2006-03-28T12:44:38

Do note my other comment.

Re:builtin prompts

rjbs on 2006-03-28T12:28:43

I want the timestamp on my prompt so that I can see, when I look back, when I executed each command. That's one of the better status lines I've seen for screen; maybe I'll use it... but as for all the promptinit, most of them are too much. Too much color, too much text, too much 1337. Some of them are alright, but I think I'll stick with my new one.

(How can people use three-line prompts? Yow!)

Re:builtin prompts

Aristotle on 2006-03-28T12:37:41

Don’t use hardstatus, use caption.

hardstatus can be affected using escape sequences from within a screen window (so you don’t want it as the bottom line), but it can passed through to the title of an xterm if you set your .screenrc up correctly (so you want something else to set up the bottom line).

Try this:

caption always '%-w%{.wB}%n %t%{-}%+w %=%{.w} %H: %l %{-}%d/%m %c'
termcapinfo xterm*|rxvt* 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' # pass hardstatus thru to xterm

WINDOW

mary.poppins on 2006-03-28T18:15:31

I just include the $WINDOW from screen in my prompt, and make sure that I always use a given screen window for the same task. Information density!

Re:WINDOW

rjbs on 2006-03-28T19:05:09

Just before lunch I was wondering whether I could use some sort of escape string to cause my .login to change the screen window's name to the hostname. That way, the sequence "C-a c ssh foo" would result in a new window that would quickly get the name "foo." I haven't consulted the manual yet, but will do today.