4 ms·
I'm using a snippet from this page: https://spin.atomicobject.com/2016/05/28/log-bash-history/ https://spin.atomicobject.com/2016/05/28/log-bash-history/ expor
by bhaak 3y ago
I'm using a snippet from this page: https://spin.atomicobject.com/2016/05/28/log-bash-history/ https://spin.atomicobject.com/2016/05/28/log-bash-history/
export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d %H:%M:%S") $(pwd) $(HISTTIMEFORMAT= history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'
This give an easily greppable shell history. An entry looks like this:
2022-10-13 09:14:54 /home/bhaak 1000 vim ~/.bashrc