summaryrefslogtreecommitdiffstats
path: root/dump-chrome-history
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2024-10-14 21:34:04 +0200
committerFlorian Pritz <bluewind@xinu.at>2024-10-14 21:54:03 +0200
commitd5ffb01d87852eb74f6b17ae06ac0c476010065b (patch)
tree1ac6a86d874f30c968ba26bf0f8a5954fa0c67a6 /dump-chrome-history
parentd10ee7703e20ef844907e90797ad66bf0fb984da (diff)
downloadbin-d5ffb01d87852eb74f6b17ae06ac0c476010065b.tar.gz
bin-d5ffb01d87852eb74f6b17ae06ac0c476010065b.tar.xz
Add new scripts
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'dump-chrome-history')
-rwxr-xr-xdump-chrome-history29
1 files changed, 29 insertions, 0 deletions
diff --git a/dump-chrome-history b/dump-chrome-history
new file mode 100755
index 0000000..d99e561
--- /dev/null
+++ b/dump-chrome-history
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")"
+trap "rm -rf '${TMPDIR}'" EXIT TERM
+
+cp -n ~/.config/chromium/Default/History "$TMPDIR"
+
+sqlite_opts=()
+
+case $MODE in
+ zsh-history-compat)
+ select_fields="last_visit_time/1000000-11644473600 AS visit_date, url, title"
+ sqlite_opts=(-separator ' | ')
+ ;;
+ *) select_fields="datetime(last_visit_time/1000000-11644473600,'unixepoch', 'localtime') AS visit_date, url, title";;
+esac
+
+output_filter() {
+ if [[ $MODE == 'zsh-history-compat' ]]; then
+ sed -r 's#^([0-9]+) \| (.*)$#: \1:0;\2#'
+ else
+ cat
+ fi
+}
+
+sqlite3 "${sqlite_opts[@]}" "$TMPDIR/History" "SELECT $select_fields
+FROM urls
+WHERE last_visit_time/1000000-11644473600 > $(date +%s -d "${1:-2 months ago}") AND last_visit_time/1000000-11644473600 < $(date +%s -d "${2:-now}")
+ORDER BY last_visit_time" | output_filter