I use some magic in $PROMPT_COMMAND
to automatically save every command I run to a database:
PROMPT_COMMAND='save_command "$(history 1)"'
where save_command
is a more complicated function. It would be nice to save also the head
/tail
of the output of each command, but I can't think of a reasonable way to do this, other than manually prepending some sort of shell function to everything I type (and this becomes even more painful with complicated pipelines or boolean expressions). Basically, I just want the first and last 10 lines of whatever went to /dev/tty
to get saved to a variable (or even a file) - is there any way to do this?