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

Re: Is there some postexec function?



On Jul 6,  5:39pm, Pascal Wittmann wrote:
}
} I wonder whether there exists a postexec function, a function that is
} called, after a command is executed. I need something like that, because
} I'm trying to print (redraw the prompt) the exit code of a program in
} the prompt where it was called.

What does "in the prompt where it was called" mean, exactly?  Can you
give an example?

If it means what it appears to, you can't do it without subverting the
edit/execute paradigm.  The line editor is active, and thus the prompt
modifiable, right up until you commit to executing the command; then
the line editor exits, the command runs, and after the command is done
a new line editor starts up with a fresh prompt.

You could create a widget that runs the command, captures its status,
and updates the prompt, all within the line editor context, but that
would do odd things with job control and pipelines.  Or you could try
to play cursor movement games to overwrite the previous prompt with
something that was output with "print -P", but depending on what the
command does with the screen that may be impractical.

} I've found some references¹ to such a function, but they didn't worked
} on my system. I'm using zsh 4.3.12.

There's never been a postexec function, that must be someone's idiom
for something they've implemented another way (perhaps through precmd
as referenced by Jeremie).



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