diff options
Diffstat (limited to 'dot_config/zsh')
-rw-r--r-- | dot_config/zsh/dot_zshrc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index 812f581..d852d4c 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -143,3 +143,42 @@ export FZFZ_RECENT_DIRS_TOOL="fasd" # Rust export PATH="${PATH}:${HOME}/.cargo/bin" + + +safari_history() { + sqlite3 -box -readonly ~/Library/Safari/History.db <<SQL +WITH ranked_visits AS ( + SELECT + datetime(history_visits.visit_time + 978307200, "unixepoch", "localtime") as time_local, + -- datetime(history_visits.visit_time + 978307200, "unixepoch") as time_utc, + -- history_visits.title, + CASE + WHEN length(history_visits.title) > 80 + THEN substr(history_visits.title, 1, 77) || '...' + ELSE history_visits.title + END as title, + -- history_items.URL, + CASE + WHEN length(history_items.URL) > 80 + THEN substr(history_items.URL, 1, 77) || '...' + ELSE history_items.URL + END as trimmed_url, + substr(history_items.URL, instr(history_items.URL, '://') + 3, + instr(substr(history_items.URL, instr(history_items.URL, '://') + 3), '/') - 1) as domain, + ROW_NUMBER() OVER ( + PARTITION BY history_visits.title, + substr(history_items.URL, instr(history_items.URL, '://') + 3, + instr(substr(history_items.URL, instr(history_items.URL, '://') + 3), '/') - 1) + ORDER BY history_visits.visit_time DESC + ) as row_num + FROM history_visits + LEFT JOIN history_items ON history_items.id = history_visits.history_item +) +-- SELECT time_local, time_utc, title, URL, trimmed_url +SELECT time_local, title, trimmed_url +FROM ranked_visits +WHERE row_num = 1 +ORDER BY time_local DESC +LIMIT 2000; +SQL +} |