Compare commits

..

1 Commits

Author SHA1 Message Date
63b7170ccb Fix bug in almostontop that truncated long prompts
Add collection of cursor line immediately after the previous command
completes and use this when calculating the number of lines required to
move the screen in order to display only the latest prompt.
2021-12-07 17:06:39 +00:00

View File

@ -132,16 +132,14 @@ fresh_line_one() {
# Executed before each prompt.
fresh_almostontop_precmd() {
# TODO: store the cursor position for use in fresh_almostontop_preexec
# CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R
printf "\033[6n"
# Discard prefix delimited by [
read -s -d [
# Store the <row> delimited by ; in fresh_precmd_row
read -s -d \; fresh_precmd_row
# Store the <row> delimited by ; in row_before
read -s -d \; row_before
# Discard suffix delimted by R otherwise it is output to the tty
read -s -d R
# printf "$fresh_precmd_row\n"
}
# Executed just after a command has been read and is about to be executed.
@ -159,7 +157,7 @@ fresh_almostontop_preexec() {
let "down = $LINES - $row"
printf "\033[${down}B"
# Calculate the number of lines in the prompt
let "prompt_lines = ($row - $fresh_precmd_row) + 2"
let "prompt_lines = ($row - $row_before) + 2"
# Print new lines to push the old command out of view
let "new = $row - $prompt_lines"
for (( i = 0; i < $new; i++ )); do