Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

reinventing print_exit_value



Hi all,

I recently decided that I want the exit code of the last command (if it's 
greater than 0) displayed after invoking it, like the PRINT_EXIT_VALUE option 
does, but in my own format. (I don't want to include it in my prompt.)
I added the necessary code to the precmd function, which lead to the following 
undesired behaviour:

% false
(1)
% <just hitting enter>
(1)
%

To achieve the intended behaviour, I now let the preexec function set a 
variable to 1, and let the precmd function print the exit value only if this 
variable is set to 1 (afterwards setting it to 0). This works because the 
preexec function is only invoked if a real command is executed, not if you 
attempt to "execute" whitespace or nothing.

However: is there a simpler way to achieve this? My solution seems a bit 
inelegant to me.

Thanks,

Christian



Messages sorted by: Reverse Date, Date, Thread, Author