Lets's say my prompt looks like this (the _ represents my cursor)
~ % _
Is there any way I could make it look like this
~ % _
[some status]
The question was originally about zsh, but now has other answers.
bashpromptzsh
Lets's say my prompt looks like this (the _ represents my cursor)
~ % _
Is there any way I could make it look like this
~ % _
[some status]
The question was originally about zsh, but now has other answers.
Best Answer
The following settings seem to work. The text on the second line disappears if the command line overflows the first line. The
preexec
function erases the second line before running the command; if you want to keep it, change topreexec () { echo; }
.%
escapes are documented in the zsh manual (man zshmisc
).Terminfo is a terminal access API. Zsh has a
terminfo
module that gives access to the terminal description database:$terminfo[$cap]
is the sequence of characters to send to exercise the terminal's capability$cap
, i.e., to run its$cap
command. Seeman 5 terminfo
(on Linux, the section number may vary on other unices) for more information.The sequence of actions is: move the cursor down one line (
cud1
), then back up (cuu1
); save the cursor position (sc
); move the cursor down one line; print[some status]
; restore the cursor position. The down-and-up bit at the beginning is only necessary in case the prompt is on the bottom line of the screen. The preexec line erases the second line (el
) so that it doesn't get mixed up with output from the command.If the text on the second line is wider than the terminal, the display may be garbled. Use Ctrl+L in a pinch to repair.