summaryrefslogtreecommitdiffstats
path: root/dump-ff-history
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2024-10-14 21:35:10 +0200
committerFlorian Pritz <bluewind@xinu.at>2024-10-14 21:54:03 +0200
commit9301f9384829645b3ac034a0c74908a6537616cf (patch)
tree3c273f900861bf6cc471ca8da44e92a5c2d947dd /dump-ff-history
parent375d4b79931fa7b407d25aaba0917a5cc0469d3b (diff)
downloadbin-9301f9384829645b3ac034a0c74908a6537616cf.tar.gz
bin-9301f9384829645b3ac034a0c74908a6537616cf.tar.xz
dump-ff-history: Add zsh-history-compat output format for my zshrc function
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'dump-ff-history')
-rwxr-xr-xdump-ff-history22
1 files changed, 20 insertions, 2 deletions
diff --git a/dump-ff-history b/dump-ff-history
index 33cf7f0..c171aa3 100755
--- a/dump-ff-history
+++ b/dump-ff-history
@@ -5,7 +5,25 @@ trap "rm -rf '${TMPDIR}'" EXIT TERM
cp -n ~/.mozilla/firefox/*.default/places.sqlite* "$TMPDIR"
-sqlite3 "$TMPDIR/places.sqlite" "SELECT datetime(visit_date/1000000,'unixepoch', 'localtime') AS visit_date, url, title
+sqlite_opts=()
+
+case $MODE in
+ zsh-history-compat)
+ select_fields="visit_date/1000000 AS visit_date, url, title"
+ sqlite_opts=(-separator ' | ')
+ ;;
+ *) select_fields="datetime(visit_date/1000000,'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/places.sqlite" "SELECT $select_fields
FROM moz_places, moz_historyvisits
WHERE moz_places.id = moz_historyvisits.place_id AND visit_date/1000000 > $(date +%s -d "${1:-2 months ago}") AND visit_date/1000000 < $(date +%s -d "${2:-now}")
-ORDER BY visit_date"
+ORDER BY visit_date" | output_filter