Skip to content

Instantly share code, notes, and snippets.

@frosit
Created April 13, 2021 02:47
Show Gist options
  • Save frosit/a79bcef89907d9ea03bd861007c5e19f to your computer and use it in GitHub Desktop.
Save frosit/a79bcef89907d9ea03bd861007c5e19f to your computer and use it in GitHub Desktop.
Chrome history export support multiple profiles
#!/bin/bash
# Original: https://gist.github.com/TravelingTechGuy/7ac464f6cccde912a6ec7a1e2f8aa96a
#
# Mac: ~/Library/Application\ Support/Google/Chrome/Default/History
#
# Adjustments:
# * Fix: for datetime
# * Mains on visits instead of url's for enhanced stats
# * exports history of every profile instead of default
#
# Issues / to do
# * properly merge exports
function exportdb(){
sqlite3 "$1" <<!
.headers on
.mode csv
.output ${2}.csv
select datetime(visit_time / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch', 'localtime') as 'date',
u.url as url,
u.title as title
from visits v
inner join urls u on
v.url = u.id;
!
}
# export all History dbs
find "${HOME}/Library/Application Support/Google/Chrome" -type f -name 'History' -print0 |
while IFS= read -r -d '' file; do
du -hs "$file"
exportdb "$file" "out"
cat out.csv >> history.csv
done
# export single db
# exportdb "${HOME}/Library/Application Support/Google/Chrome/Default/History" "history"
# export a specific profile
# exportdb "${HOME}/Library/Application Support/Google/Chrome/Profile 3/History" "history-3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment