@@ -88,36 +88,29 @@ PS2="${PROMPT_SECONDARY_INDICATOR} "
8888
8989# ##### Handle Exit Codes #######################################################
9090
91- _prompt_exec_flag= ' false '
92- function _prompt_flag_exec {
93- _prompt_exec_flag =' true'
91+ typeset -g _prompt_line_executed
92+ function _prompt_preexec {
93+ _prompt_line_executed =' true'
9494}
9595
96- function _prompt_handle_exit_code {
97- local exit_code=$status
98- if [ $exit_code != 0 ]; then
99- if [[ $_prompt_exec_flag == ' true' ]]; then
100- printf " \033[2K" # \033[2K\r prevents strange line wrap behaviour when resizing terminal window
101- printf " ${fg_bold[red]} ✖ ${exit_code}${reset_color} \n"
96+ function _prompt_precmd {
97+ local exit_status=$status
98+ if [[ $_prompt_line_executed == ' true' ]]; then
99+ _prompt_line_executed=' false'
100+ if [[ $exit_status != 0 ]]; then
101+ printf " \033[2K\r" # \033[2K\r prevents strange line wrap behaviour when resizing terminal window
102+ printf " ${fg_bold[red]} ✖ ${exit_status}${reset_color} \n"
102103 fi
104+ elif [[ $ZLE_LINE_ABORTED ]] && [[ $_ZSH_HIGHLIGHT_PRIOR_BUFFER ]]; then
105+ printf " \033[2K\r" # \033[2K\r prevents strange line wrap behaviour when resizing terminal window
106+ printf " ${fg_bold[grey]} ✖ ${exit_status}${reset_color} \n"
103107 fi
104- _prompt_exec_flag=' false'
105108}
106109
107- preexec_functions=(_prompt_flag_exec $preexec_functions )
108- precmd_functions=(_prompt_handle_exit_code $precmd_functions )
110+ preexec_functions=(_prompt_preexec $preexec_functions )
111+ precmd_functions=( _prompt_precmd $precmd_functions )
109112
110- # print exit code when commandline is interupted
111- function _promp_handle_interupt {
112- if [ " $SUFFIX_ACTIVE " = 0 ] && [ -n " ${PREBUFFER}${BUFFER} " ]; then
113- local exit_code=130
114- printf " \n\033[2K" # \033[2K\r prevents strange line wrap behaviour when resizing terminal window
115- printf " ${fg_bold[grey]} ✖ ${exit_code}${reset_color} "
116- fi
117- }
118- trap " _promp_handle_interupt; return INT" INT
119-
120- # ##### clear screen with prompt info ###########################################
113+ # ##### clear s creen with prompt info ###########################################
121114
122115function _clear_screen_widget {
123116 tput clear
0 commit comments