Skip to content

Instantly share code, notes, and snippets.

@kai-qu
Last active March 27, 2019 15:36
Show Gist options
  • Save kai-qu/d84d94d05e8ce974d12cdfd101123da7 to your computer and use it in GitHub Desktop.
Save kai-qu/d84d94d05e8ce974d12cdfd101123da7 to your computer and use it in GitHub Desktop.
Please run the script on a copy of your history and not the actual history file. This script only works on bash history. See usage instructions below. (code by Gaurav Manek)
#!/usr/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
IFS=' =' read -r -a array <<< "$line"
for index in "${!array[@]}"
do
if [ $index -eq 0 ] || [[ "${array[index]:0:1}" == "-" ]]; then
printf "%s\t" "${array[index]} "
else
printf "%s\t" $(echo "${array[index]}" | md5sum | cut -c-32)
fi
done
printf "\n"
done
@priyald17
Copy link

For zsh, you can do the following:
cat <filename> | cut -d\; -f2 | ./sanitize.sh > myhistory.tsv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment