Ask HN: How to Extract Shell Commands from Raw PTY Sessions? (Rewindtty)

debba | 2 points

For bash, you can use `trap [code] DEBUG` to run your code before the command executes. $BASH_COMMAND should be the set to the command that's going to run.

Alternatively, look at the $PROMPT_COMMAND which runs before printing the $PS1 prompt (so maybe you could check `history 1` to get the command afterwards)

ksherlock | 2 days ago