From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25223 invoked from network); 15 Nov 2001 23:08:03 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 15 Nov 2001 23:08:03 -0000 Received: (qmail 25824 invoked by alias); 15 Nov 2001 23:07:50 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4478 Received: (qmail 25810 invoked from network); 15 Nov 2001 23:07:49 -0000 From: Deborah Ariel Pickett Message-Id: <200111152307.fAFN7dc27614@bruce.csse.monash.edu.au> Subject: Re: Prompt erases line To: lewang@yahoo.com (Le Wang) Date: Fri, 16 Nov 2001 10:07:39 +1100 (EST) Cc: zsh-users@sunsite.dk (Zsh-users List) In-Reply-To: <20011115224905.67345.qmail@web12301.mail.yahoo.com> from "Le Wang" at Nov 15, 2001 05:49:05 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > The zsh propmpt always seem to erase the line if the > line does not end in a "\n" > ----- > lewang@phobe ~ % echo asdf > asdf > lewang@phobe ~ % echo -n adsf > lewang@phobe ~ % > ----- > Is there any way to get it to just print the prompt > after the text on the same line? unsetopt PROMPT_CR This is assuming that you don't have a carriage return character in your PS1 shell variable. Put it in your $HOME/.zshrc file if you want it to behave that way every time you start a shell. Be aware that unsetting PROMPT_CR can cause some unusual behaviour with the zle editor, because it has no way of knowing how many characters have already been printed on the line before the prompt. On an aside, I used to have the following code in my precmd function, which would detect if the cursor wasn't up against the left edge of the screen using an xterm/VT100 escape sequence. If the cursor wasn't in the first column, the precmd function would print a message and arrange for the prompt to be printed anew on the line below. It was a cute feature, but I've since disabled it because it was too slow to use seriously, and timing issues meant that it didn't always work across a slow (dialup) connection. It would have worked a bit quicker if the "STTY='opts' command" trick worked on the print/read combination in the middle of the report-cursor-position function (thus removing two fork/execs to the external stty command), but I couldn't make it work. Besides, the whole thing was pretty useless, to be honest. To use it, set PROMPTCURSORPOS to a number such as 10. This is the number of milliseconds the function waits for a response from the terminal driver. # report-cursor-position # Returns the horizontal cursor position for xterms and other terminals. # The returned number is zero-origin, so a "successful" (in shell terms) # return means the cursor is at the left edge of the screen. # # This code is lifted from an example in the xterm FAQ # written by Icarus Sparry 11 Apr 1997 # and modified to use a different control sequence. report-cursor-position() { local old a if [[ $TERM = xterm* ]] then # Send the terminal the code and wait for its response. exec /dev/tty IFS='' read -r a stty $old a=${${a##*;}%%R*} return $(( $a - 1 )) fi } precmd() { # .... other stuff ... # Check the cursor position - is it up against the left margin? # This can be kind of slow, so we only do it if a shell variable is # set (which it isn't by default - see below). if [[ ${+PROMPTCURSORPOS} -eq 1 ]] then # This function works on xterms and other assorted terminals # by querying the terminal for its cursor position. It returns zero # if the cursor is in the leftmost position, nonzero otherwise. if ! report-cursor-position $PROMPTCURSORPOS then print "[no newline]" fi fi # .... other stuff ... } -- Debbie Pickett http://www.csse.monash.edu.au/~debbiep debbiep@csse.monash.edu.au If I throw a stick, will you leave? - button slogan