Bash tips, tricks and code snippets
Command line logging history
This source has an excellent tip for maintaining a log of bash commands.
Create a directory
then add the following to the
export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'
After logging out and in again the history logging will be active.
~/.logs/ must exist and be writable!