From f0caedc213bde7153a6b430222eec2178ac21d31 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 4 Jul 2017 22:34:45 +0400 Subject: [PATCH] Google chrome history for OSX/linux --- Examples.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Examples.md b/Examples.md index cadcd3d..2d2d542 100644 --- a/Examples.md +++ b/Examples.md @@ -22,7 +22,7 @@ Table of Contents * [With fz.](#with-fz) * [With fasd.](#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 } ```