News for hackers. Stuff that matters.
Re:Xonsh – A Python-Powered Shell by lloeki on Wednesday February 26, 2025 @03:31AM (#43181884)
> bash won't let me automatically run a command before and after each interactive command I execute, which I want for task completion notifications

Incorrect. This can be achieved because I've done it ;)

It relies on trap DEBUG (preexec) and PROMPT_COMMAND (precmd), but to make this much easier for me I've ported zsh preexec and precmd callback support to bash:

https://github.com/lloeki/dotfiles/blob/master/bash/ext

Then with those callbacks now available it is quite easy to e.g compute time between command start and command end:

https://github.com/lloeki/dotfiles/blob/master/bash/rc

(The time thing is commented out because I don't need it right now, I used it to display command exec time on the prompt. Note that bash EPOCHREALTIME has second-level precision)

And from there notifying completion of commands that run longer than X is absolutely trivial.

Other things I've "backported":

- chpwd callback

- the %\n thing on lack of newline in command output

- PROMPT and RPROMPT

- zprompt colors

There are no comments on this comment yet.