Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browsing Safari history with fzf? #1204

Closed
4 of 15 tasks
ghost opened this issue Jan 20, 2018 · 2 comments
Closed
4 of 15 tasks

Browsing Safari history with fzf? #1204

ghost opened this issue Jan 20, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 20, 2018

  • Category
    • fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Windows Subsystem for Linux
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

browsing-chrome-history-with-fzf sounds neat, does someone know how to deal with Safari which afaik has .plist files for its history? It's ~/Library/Safari/History.db as a sqlite3

I've now git it somewhat working by using

c() {
  local cols sep
  cols=$(( COLUMNS / 3 ))
  sep='{::}'

  cp -f ~/Library/Safari/History.db /tmp/h

  sqlite3 -separator $sep /tmp/h \
    "select substr(id, 1, $cols), url
     from history_items" |
  awk -F $sep '{printf "%-'$cols's  \x1b[36m%s\x1b[m\n", $1, $2}' | grep "http|https" |
  fzf --ansi --multi | sed 's#.*\(https*://\)#\1#' | xargs open

where this is what the database seems to hold

history_client_versions  history_items            metadata
history_event_listeners  history_tombstones
history_events           history_visits

CREATE TABLE history_items (id INTEGER PRIMARY KEY AUTOINCREMENT,url TEXT NOT NULL UNIQUE,domain_expansion TEXT NULL,visit_count INTEGER NOT NULL,daily_visit_counts BLOB NOT NULL,weekly_visit_counts BLOB NULL,autocomplete_triggers BLOB NULL,should_recompute_derived_visit_counts INTEGER NOT NULL,visit_count_score INTEGER NOT NULL);
CREATE INDEX history_items__domain_expansion ON history_items (domain_expansion);

maybe someone can tell me how to do this in a proper command

@edi9999
Copy link
Contributor

edi9999 commented Jan 26, 2018

What is wrong with the command ?

@ghost
Copy link
Author

ghost commented Jan 26, 2018

I was not sure I did it correctly since I've never used sql before. (I have no idea what select substr(id, 1, $cols) is doing especially)
Now I'm using

c() {
  local cols sep
  cols=$(( COLUMNS / 3 ))
  sep='{::}'

  cp -f ~/Library/Safari/History.db /tmp/h

  sqlite3 -separator $sep /tmp/h \
    "select substr(id, 1, $cols), url
     from history_items order by visit_count_score desc" |
  awk -F $sep '{printf "%-'$cols's  \x1b[36m%s\x1b[m\n", $1, $2}'  |
  fzf --ansi --multi | sed 's#.*\(https*://\)#\1#' | xargs open
}

so removed the ugly grep part and added sorting...

it's probably good to close

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant