From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15933 invoked by alias); 4 Aug 2014 19:31:33 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32956 Received: (qmail 10785 invoked from network); 4 Aug 2014 19:31:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140804123106.ZM1786@torch.brasslantern.com> Date: Mon, 04 Aug 2014 12:31:06 -0700 In-reply-to: Comments: In reply to "Felipe G. Silveira" "Possible bug to RPROMPT" (Aug 1, 5:20am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Felipe G. Silveira" , zsh-workers@zsh.org Subject: Re: Possible bug to RPROMPT MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 1, 5:20am, Felipe G. Silveira wrote: } } Since I setup my PROMPT so the information comes in one line and my cursor } below it, I was trying to align the RPROMPT to always appear 1 line before } where it generally is printed. If I understand correctly, what you want is: First_line_of_PROMPT_here...................................RPROMPT_here Second_line.cursor where I have used dots in place of whitespace in case of line wrap. } so after some tinkering, I decided to try some escape commands: } } PROMPT=$'\e[s'$'\e[1A''< [clock] ''$'\e[1B'$'\e[u' You have the right general idea (though there are too many quotes in that line) but have overlooked the %{ and %} prompt formats, which help ZLE to compute the start and end positions of the prompt text. If you move the cursor with terminal escapes while inside the prompt, you must wrap the "zero width" parts in %{...%} so ZLE won't count them when it calculates the number of columns occupied by the prompt. In the case of your specific desire, you can probably get away with using only vertical motions (no save/restore of cursor) like so: PROMPT="First_line_of_PROMPT_here"$'\n'"Second_line " RPROMPT=$'%{\e[1A%}'"RPROMPT_here"$'%{\e[1B%}' This just says that the right prompt begins with a zero-width motion, which happens to be "up one line", and ends with another zero-width motion, "down one line". Because ZLE only cares about the horizontal position for its calculations, as long as you make sure the cursor starts and ends on the same line it all works out. Note, though, that if "First_line_of_PROMPT_here" is wide enough to overlap with "RPROMPT_here", the RPROMPT will write over it. Also, the TRANSIENT_RPROMPT option will have no effect because the text is one line above where ZLE expects it to be. For a more complicated example of a prompt that looks like what you want but does not use RPROMPT to accomplish it, read the "Prompt Themes" section of "man zshcontrib" and then try "prompt -h bart".