diff options
-rw-r--r-- | basta.sh | 33 |
1 files changed, 24 insertions, 9 deletions
@@ -68,18 +68,30 @@ basta.update_status() printf "${esc}7$esc[%s;1H$esc[K%s$esc[1;%sr${esc}8" $((LINES + 1)) "$status" $LINES } -basta.before_prompt() +basta.check_cursor() { - local exit=$? - local esc=$(printf "\033") - local curln=$(basta.get_cur_line) - local getcmdno='\#' - local cmdno=${getcmdno@P} + local saved_tty=$(stty -g) + stty raw - if [ $curln -gt $LINES ]; then - printf "$esc[%s;1H" $LINES + if ! read -t 0; then + local exit=$? + local esc=$(printf "\033") + local curln=$(basta.get_cur_line) + + if [ $curln -gt $LINES ]; then + printf "$esc[%s;1H" $LINES + fi fi + stty "$saved_tty" +} + +basta.do_exit_status() +{ + local exit=$1 + local getcmdno='\#' + local cmdno=${getcmdno@P} + if [ $exit -ne 0 -a $cmdno -ne $basta_old_cmdno ] ; then printf "!%s!\n" $exit fi @@ -87,9 +99,12 @@ basta.before_prompt() basta_old_cmdno=$cmdno } + basta.prompt_hook() { - basta.before_prompt + local exit=$? + basta.check_cursor + basta.do_exit_status $exit basta.update_status } |