Skip to content

Instantly share code, notes, and snippets.

@Arr0way
Last active August 29, 2015 14:05
Show Gist options
  • Save Arr0way/00793f9cd743956dcd7f to your computer and use it in GitHub Desktop.
Save Arr0way/00793f9cd743956dcd7f to your computer and use it in GitHub Desktop.
Super Awesome Bash History Logger for OSX V1.0 - Might work in Linux
##########################################################################################################
# | #
# . | Super Awesome Bash History Logger for OSX V1.0 #
# .. ............;;. | #
# ..:: @Arr0way ;;;;. | Disclaimer: Use at your own risk. #
# . . ::::::::::::;;:' | #
# :' | Enjoy. #
# | #
# #
# Save your console commands and your sanity. #
# #
# cd ~/.history/ && grep -R "ls" bash-history* #
# #
# Log file naming structure: #
# #
# --------------YYYYMMDD.HHMMSS-NUMB-USER-CONSOLE #
# .bash-history-20140814.153100-9284-sara-ttys003 #
# #
# This should work on Linux but I have not tested. #
# #
# Usage: Copy and paste the lines below into your ~/.bash_profile file #
# #
##########################################################################################################
DATESTAMP=$(date '+%Y%m%d.%H%M%S')
if [ ! -d ${HOME}/.history_files ]
then
mkdir ${HOME}/.history_files
fi
HN=$(who -m | awk '{print $1"-"$2}')
export HISTFILE="${HOME}/.history_files/.bash-history-${DATESTAMP}-$$-${HN}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment