m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 00:03:39 -05:00

Google chrome history for OSX/linux

Julien
2017-07-04 22:34:45 +04:00
parent e4783c3d47
commit f0caedc213

@@ -22,7 +22,7 @@ Table of Contents
* [With <a href="https://github.com/changyuheng/fz">fz</a>.](#with-fz)
* [With <a href="https://github.com/clvv/fasd">fasd</a>.](#with-fasd-1)
* [Shell bookmarks](#shell-bookmarks)
* [Google Chrome (OS X)](#google-chrome-os-x)
* [Google Chrome (OS X/linux)](#google-chrome-os-xlinux)
* [Browsing history](#browsing-history)
* [Bookmarks](#bookmarks)
* [Browsing](#browsing)
@@ -587,26 +587,30 @@ Yet another useful application for `fzf`: shell bookmarks. It looks as follows:
See complete article for details: [Fuzzy bookmarks for your shell](http://dmitryfrank.com/articles/shell_shortcuts)
### Google Chrome (OS X)
### Google Chrome (OS X/linux)
#### Browsing history
```sh
# c - browse chrome history
c() {
local cols sep
local cols sep google_history open
cols=$(( COLUMNS / 3 ))
sep='{{::}}'
# Copy History DB to circumvent the lock
# - See http://stackoverflow.com/questions/8936878 for the file path
cp -f ~/Library/Application\ Support/Google/Chrome/Default/History /tmp/h
sep='{::}'
if [ "$(uname)" = "Darwin" ]; then
google_history="$HOME/Library/Application Support/Google/Chrome/Default/History"
open=open
else
google_history="$HOME/.config/google-chrome/Default/History"
open=xdg-open
fi
cp -f "$google_history" /tmp/h
sqlite3 -separator $sep /tmp/h \
"select substr(title, 1, $cols), url
from urls order by last_visit_time desc" |
awk -F $sep '{printf "%-'$cols's \x1b[36m%s\n", $1, $2}' |
fzf --ansi --multi | sed 's#.*\(https*://\)#\1#' | xargs open
awk -F $sep '{printf "%-'$cols's \x1b[36m%s\x1b[m\n", $1, $2}' |
fzf --ansi --multi | sed 's#.*\(https*://\)#\1#' | xargs $open > /dev/null 2> /dev/null
}
```