3 ms·
> (bash won't let me automatically run a command before and after each interactive command I execute, which I want for task completion notifications Not to pu
by isr 2y ago
> (bash won't let me automatically run a command before and after each interactive command I execute, which I want for task completion notifications
Not to put you off investigating alternative shells (I've spent time with rc shell, xonsh (and tako), and even turned gauche scheme & tcl into a commandline shell), but isn't your bash problem solved by using $PS1 to launch your own functions to do whatever?
At least, you can use $PS1 for the "after command" bit. For pre-command, just use a simple 1 letter wrapped script which does whatever, and then exec's the remaining arguments (aka "Bernstein chaining")
(unless I've gotten the wrong end of the stick, and am missing what you meant)
- rendaw 2y agoNo, not at all! Yeah I could do that, and it's something I considered, but I feel like working in a shell shouldn't be such an unrelenting hack. FWIW I think every shell _but_ bash supports it, I was just hoping to move to something that's overall nice to use in the process.
- belden 2y agoI wonder if bash-preexec https://github.com/rcaloras/bash-preexec https://github.com/rcaloras/bash-preexec could be used here. Perhaps you could start a timer in a preexec, and stop it in precmd. If the elapsed time is greater than some value, notify-send yourself a message that a long-running command has finished.
- shiomiru 2y agoAnother solution for the pre-command part is "trap 'some command' DEBUG".
- isr 2y agoDidn't know about that. Thanks!