diff --git a/Examples.md b/Examples.md index 28861bc..f3beec0 100644 --- a/Examples.md +++ b/Examples.md @@ -35,7 +35,7 @@ Table of Contents * [With fz.](#with-fz) * [With fasd.](#with-fasd-1) * [Shell bookmarks](#shell-bookmarks) -* [Google Chrome (OS X/linux)](#google-chrome-os-xlinux) +* [Google Chrome](#google-chrome) * [Browsing history](#browsing-history) * [Bookmarks](#bookmarks) * [Browsing](#browsing) @@ -1204,10 +1204,11 @@ 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/linux) +### Google Chrome #### Browsing history +OSX/Linux Version: ```sh # c - browse chrome history c() { @@ -1231,6 +1232,23 @@ c() { } ``` +Windows Version: +```ps1 +Function c() { + $Columns = [int]((get-host).ui.rawui.WindowSize.Width / 3) + $Separator ='{::}' + $History = "$env:USERPROFILE\AppData\Local\Google\Chrome\User Data\Default\History" + $TempFile = New-TemporaryFile + $Query = "select substr(title, 1, $Columns), url from urls order by last_visit_time desc" + Copy-Item $History -Destination $TempFile + @(sqlite3 -separator "$Separator" "$TempFile" "$Query") | + ForEach-Object { + $Title, $Url = ($_ -split $Separator)[0, 1] + "$($Title.PadRight($Columns)) `e[36m$Url`e[0m" + } | fzf --ansi --multi | ForEach-Object{start-process "chrome.exe" ($_ -replace '.*(https*://)', '$1'),'--profile-directory="Default"'} +} +``` + #### Bookmarks Chrome Bookmarks browser with [jq](https://stedolan.github.io/jq/) for OS X @@ -1251,6 +1269,28 @@ b() { } ``` +Chrome Bookmarks browser with [jq](https://stedolan.github.io/jq/) for Windows +``` +# b - browse chrome bookmarks +Function b() { + $Bookmarks = "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Bookmarks" + + $JqScript=@" + def ancestors: while(. | length >= 2; del(.[-1,-2])); + . as `$in | paths(.url?) as `$key | `$in | getpath(`$key) | {name,url, path: [`$key[0:-2] | ancestors as `$a | `$in | getpath(`$a) | .name?] | reverse | join(\`"/\`") } | .path + \`"/\`" + .name + \`"|\`" + .url +"@ + + Get-Content "$Bookmarks" | jq -r "$JqScript" ` + | ForEach-Object { + $_ -replace "(.*)\|(.*)", "`$1`t`e[36m`$2`e[0m" + } ` + | fzf --ansi ` + | ForEach-Object { + start-process "chrome.exe" ($_ -split "`t")[1],'--profile-directory="Default"' + } +} +``` + Chrome Bookmarks browser with ruby https://gist.github.com/junegunn/15859538658e449b886f (for OS X)