Add this to ~/.profile
function previous_command_status()
{
if [ $? -eq 0 ]; then
~/logging.sh
fi
}
PROMPT_COMMAND='previous_command_status'
add this to ~/logging.sh
and change the IP address to the IP address of the computer that's running the application
ipaddress="xxx.xxx.xxx.xxx:8000"
last=$1
prev=$(fc -ln -1)
while true; do
echo -n "Do you want to log this command? [Y/n] "
read yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) exit;;
esac
done
curl --request POST "http://$ipaddress/api/log/cli" --data "how=$prev" --data --data "with=Terminal"