Last active
June 19, 2018 23:05
-
-
Save HarrisonMc555/4a0d708def7db2b9c12da739e43d8861 to your computer and use it in GitHub Desktop.
Save everything command entered at the terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p ~/.logs | |
export PROMPT_COMMAND=' | |
CODE=$? | |
if [ "$(id -u)" -ne 0 ]; then | |
COMMAND_NUMBER=$(history 1 | awk '\''{ print $1 }'\'') | |
COMMAND=$(history 1 | awk '\''{ s = ""; for (i = 2; i <= NF; i++) s = s $i " "; print s }'\'') | |
COMMAND=${COMMAND%%*( )} | |
printf "$(date "+%H:%M:%S")\t$(pwd)\t${COMMAND_NUMBER}\t${COMMAND}\t${CODE}\n" >> \ | |
~/.logs/bash-history-$(date "+%Y-%m-%d").log | |
fi' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment