zsh-users
 help / color / mirror / code / Atom feed
* zsh 3pre2: carriage return in prompt
@ 1996-07-11  6:01 Timothy J. Luoma
  1996-07-11 13:55 ` Zoltan Hidvegi
  0 siblings, 1 reply; 8+ messages in thread
From: Timothy J. Luoma @ 1996-07-11  6:01 UTC (permalink / raw)
  To: zsh-users


I had been using this as my prompt:

PROMPT='[%h] [OLD: $OLDPWD] [CURRENT: %~] $(echo "\n")'

That gave me the information I wanted, and a carriage return at the  
end of the line, so my commands always began at the left margin.

This no longer works with 3.pre2.  Has something changed that makes  
this impossible? All I want is something that looks like this:

[localhost] [OLD: /old/path] [CURRENT: ~current]
X

where X represents where the cursor would be located

Thanks!
TjL


--------------------------------------------------------------------
Timothy J. Luoma <luomat@nerc.com>
NeXTMail adored! (MIME/SUN also accepted)
NeXT info via email: send message with SUBJECT: send-ascii info
Now in infancy: http://www.nerc.com/~luomat



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

* Re: zsh 3pre2: carriage return in prompt
  1996-07-11  6:01 zsh 3pre2: carriage return in prompt Timothy J. Luoma
@ 1996-07-11 13:55 ` Zoltan Hidvegi
  1996-07-11 16:47   ` Timothy J. Luoma
  0 siblings, 1 reply; 8+ messages in thread
From: Zoltan Hidvegi @ 1996-07-11 13:55 UTC (permalink / raw)
  To: luomat; +Cc: zsh-users

> 
> I had been using this as my prompt:
> 
> PROMPT='[%h] [OLD: $OLDPWD] [CURRENT: %~] $(echo "\n")'
> 
> That gave me the information I wanted, and a carriage return at the  
> end of the line, so my commands always began at the left margin.
> 
> This no longer works with 3.pre2.  Has something changed that makes  
> this impossible? All I want is something that looks like this:

Yes.  Quote from man zshexpn:

COMMAND SUBSTITUTION
       A  command  enclosed  in  parentheses preceded by a dollar
       sign, like so: $(...) or quoted with grave accents:  `...`
       is  replaced  with  its standard output, with any trailing
       newlines deleted.

But really using $(echo "\n") is a quite expensive solution.  It requires a
fork().  You can just simply write

PROMPT='[%h] [OLD: $OLDPWD] [CURRENT: %~]
'

If you use csh_junkie_paren, turn it of, or put a backslash at the end of
the line.

Zoltan



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

* Re: zsh 3pre2: carriage return in prompt
  1996-07-11 13:55 ` Zoltan Hidvegi
@ 1996-07-11 16:47   ` Timothy J. Luoma
  1996-07-11 17:51     ` On the topic of prompts DeWitt Clinton
  0 siblings, 1 reply; 8+ messages in thread
From: Timothy J. Luoma @ 1996-07-11 16:47 UTC (permalink / raw)
  To: Zoltan Hidvegi; +Cc: zsh-users

Zoltan Hidvegi on Thu, 11 Jul 1996 wrote:
> But really using $(echo "\n") is a quite expensive solution. It
> requires a fork().  You can just simply write
> 
> PROMPT='[%h] [OLD: $OLDPWD] [CURRENT: %~]
> '
> 
> If you use csh_junkie_paren, turn it of, or put a backslash at the
> end of the line.


Strange, this will work at the commandline, but not if I put it in the .zshenv.

I've turned off the csh-stuff and even tried the backslash, I don't know what else to try, so for now I'm still using an old zsh....

System: NeXT 3.2 m68k

TjL


--------------------------------------------------------------------
Timothy J. Luoma <luomat@nerc.com>  
NeXTMail adored! (MIME/SUN also accepted)
NeXT info via email: send message with SUBJECT: send-ascii info
Now in infancy: http://www.nerc.com/~luomat



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

* On the topic of prompts
  1996-07-11 16:47   ` Timothy J. Luoma
@ 1996-07-11 17:51     ` DeWitt Clinton
  1996-07-11 23:00       ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: DeWitt Clinton @ 1996-07-11 17:51 UTC (permalink / raw)
  To: zsh-users

Hi,

I've been lurking here for a while, and while I don't take full advantage
of everything zsh offers, I am still a strong supporter.

I just recently switched to a two line prompt (embedding a literal newline
works fine for me) and I have a question.  I used to use rprompt to place
the time on the right hand side.  Now I would like the time to be right
justified on the first line of the prompt.  So it would look something
like:

- history hostname username cwd date          time -
%

Simply using rprompt would give me:

- history hostname username cwd date                             
%                                             time -

Since there is probably no way to justify a section of the prompt, perhaps
there is a way to tell rprompt to write to the line just above using
control characters?  Just wondering...

Also, is there a way to pad the variables with spaces?  If so, that would 
solve this problem entirely.

While I am thinking about it, what I am really looking for is a status bar
that would just sit at the top of the screen and hold certain useful
information.  Anyone know of how to achieve this?

-DeWitt

DeWitt Clinton                                       dewitt@siva.tripod.com
(413) 458-2265 at Tripod, Inc.                       (413) 458-2107 at home.




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

* Re: On the topic of prompts
  1996-07-11 17:51     ` On the topic of prompts DeWitt Clinton
@ 1996-07-11 23:00       ` Bart Schaefer
  1996-07-12 18:36         ` Jose Unpingco
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 1996-07-11 23:00 UTC (permalink / raw)
  To: DeWitt Clinton, zsh-users

On Jul 11,  1:51pm, DeWitt Clinton wrote:
> Subject: On the topic of prompts
>
> Since there is probably no way to justify a section of the prompt, perhaps
> there is a way to tell rprompt to write to the line just above using
> control characters?  Just wondering...

Sure.  Note that the following won't work properly if you don't have a
newline in PS1.

RPS1="%{$(echotc ku)%}whatever you want here%{$(echotc kd)%}"

You might have to replace $(echotc ku) and $(echotc kd) with different
up and down escapes for your terminal if your terminal has a keypad
transmit mode, because keypad mode is normally not in use.

I tried $(echotc up) and $(echotc do) but that doesn't work because "do"
is frequently just ctrl-J, which zsh strips out of rprompts.

> Also, is there a way to pad the variables with spaces?  If so, that would 
> solve this problem entirely.

Sort of.

precmd() {
    fakePS1=$(print -nP " %h %m %n %~ %W")
    unset fakeRPS1	# Clear any previous `typeset -R`
    fakeRPS1=$(print -nP %@)
    if [[ $[$COLUMNS-$#fakePS1-$#fakeRPS1-2] -gt 0 ]]
    then
	typeset -R $[$COLUMNS-$#fakePS1-1] fakeRPS1="$fakeRPS1"
	PS1="$fakePS1$fakeRPS1
% "
    else
	PS1="$fakePS1
% "
    fi
}

> While I am thinking about it, what I am really looking for is a status bar
> that would just sit at the top of the screen and hold certain useful
> information.  Anyone know of how to achieve this?

You can play all sorts of games with %{...%} and termcap sequences if
your terminal can set scrolling regions and so forth.  If you're using
an xterm, you can use something like this to change the title bar:

if [[ "$TERM" = xterm* || "$TERM" = vs100 || "$TERM" = vs100s ]]
then
    # Set top to introduce titlebar change
    top='^[]0;'
    # Set back to end titlebar change
    back='\a'
    # Create precmd() to put stuff in the title bar
    precmd() { print -nP "%{$top%m.%l:%2c - %t$back%}" }
fi

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"



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

* Re: On the topic of prompts
  1996-07-11 23:00       ` Bart Schaefer
@ 1996-07-12 18:36         ` Jose Unpingco
  1996-07-13  2:42           ` Bart Schaefer
  1996-07-16  6:25           ` Nikita Borisov
  0 siblings, 2 replies; 8+ messages in thread
From: Jose Unpingco @ 1996-07-12 18:36 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-users

I've thought about sticking a highlighted status line on the last line
of a vt100 or xterm which would contain handy info like PWD, but I
could never figure out how. Could you be more specific about what you
mention below? I've never programmed a terminal before and I'm not
sure what you mean by games with the "termcap sequences".

thanks

Bart Schaefer said:
> 
> You can play all sorts of games with %{...%} and termcap sequences if
> your terminal can set scrolling regions and so forth.  If you're using
> an xterm, you can use something like this to change the title bar:
> 
> if [[ "$TERM" =3D xterm* || "$TERM" =3D vs100 || "$TERM" =3D vs100s ]]
> then
>     # Set top to introduce titlebar change
>     top=3D'=1B]0;'
>     # Set back to end titlebar change
>     back=3D'=07'
>     # Create precmd() to put stuff in the title bar
>     precmd() { print -nP "%{$top%m.%l:%2c - %t$back%}" }
> fi
> 

-- 
Thank you for your time and consideration.  

             _ - - - _                             
           /)-  - _     _                          
          / |_o_/  -       _        
              \__  -          _        
                \ \_              -   _  _  _  _   _  _  _  _  _       
                 _                      
   __ __ _ _  -        
Jose Unpingco 
ECE 0407
(619) 546-8809



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

* Re: On the topic of prompts
  1996-07-12 18:36         ` Jose Unpingco
@ 1996-07-13  2:42           ` Bart Schaefer
  1996-07-16  6:25           ` Nikita Borisov
  1 sibling, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 1996-07-13  2:42 UTC (permalink / raw)
  To: Jose Unpingco; +Cc: zsh-users

On Jul 12, 11:36am, Jose Unpingco wrote:
} Subject: Re: On the topic of prompts
}
} I've thought about sticking a highlighted status line on the last line
} of a vt100 or xterm which would contain handy info like PWD, but I
} could never figure out how. Could you be more specific about what you
} mention below? I've never programmed a terminal before and I'm not
} sure what you mean by games with the "termcap sequences".

Since programming a terminal is not something I do for entertainment,
I was hoping *not* to be specific. :-)  However:

If you look at the termcap database, the "cs" capability is the "change
scrolling region" escape sequence.  So, supposing you have an 80x24
screen, AND your terminal supports scrolling regions, AND your termcap
is complete enough to include the "cs" capability (many aren't), THEN
you can do this sort of thing:

	# Remember that zsh numbers lines/columns from 0 (zero)!
	# Also, for some reason, zsh reads termcap args in reverse order,
	# so although the cs string wants to use 1;23, zsh has to be told
	# 23 and then 1.  Similarly for cm.  Is this a bug?

	precmd() {
	    echotc cs $[$LINES-1] 1	# Set scrolling region
	    echotc cm 0 0		# Move cursor to first line
	    print -nP "%S$ZSH_NAME $ZSH_VERSION%s %h %m %n %W %@"
	    echotc cm 0 $[$LINES-1]	# Move cursor to last line
	}

One thing you have to remember is to reset the scrolling region to the
full screen before you run commands like "less", "more", or "vi".  That
means you may have to set up a whole bunch of functions like:

	more() {
	    [[ -t 1 ]] && echotc cs $[$LINES-1] 0	# Full-screen scroll
	    command more $*
	}

Also note that strange things may happen if you try to print more than
one line into the space above the scrolling region.

Specific enough?

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"



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

* Re: On the topic of prompts
  1996-07-12 18:36         ` Jose Unpingco
  1996-07-13  2:42           ` Bart Schaefer
@ 1996-07-16  6:25           ` Nikita Borisov
  1 sibling, 0 replies; 8+ messages in thread
From: Nikita Borisov @ 1996-07-16  6:25 UTC (permalink / raw)
  To: Jose Unpingco; +Cc: zsh-users

> I've thought about sticking a highlighted status line on the last line
> of a vt100 or xterm which would contain handy info like PWD, but I
> could never figure out how. Could you be more specific about what you
> mention below? I've never programmed a terminal before and I'm not
> sure what you mean by games with the "termcap sequences".

Note that if you're using an xterm, you can use the handy escape
sequences to put things like the PWD into window title and/or icon name
of the xterm:

<ESC>]n;text<^G>

where ESC and ^G are the appropriate ascii codes, and n is 2,1, or 0, to
put text in the window title, icon name, or both respectively.  I use:

if tty -s && [[ "$TERM" = "xterm" ]]; then
    chpwd () {
        echo -n "<ESC>]2;$PWD<^G>"
    }
fi

in my .zshrc to set the title bar of the xterm to my current directory.



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

end of thread, other threads:[~1996-07-16  6:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-11  6:01 zsh 3pre2: carriage return in prompt Timothy J. Luoma
1996-07-11 13:55 ` Zoltan Hidvegi
1996-07-11 16:47   ` Timothy J. Luoma
1996-07-11 17:51     ` On the topic of prompts DeWitt Clinton
1996-07-11 23:00       ` Bart Schaefer
1996-07-12 18:36         ` Jose Unpingco
1996-07-13  2:42           ` Bart Schaefer
1996-07-16  6:25           ` Nikita Borisov

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).