Created
March 1, 2024 02:54
-
-
Save blueforesticarus/edab1c28fa0ee1794e6f6890e859145b to your computer and use it in GitHub Desktop.
nushell script to parse (and interactively select using skim) brave browser history and bookmarks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nu | |
let BRAVE = ( glob ~/.config/BraveSoftware/Brave-Browser/Default/).0 | |
def _history [] { | |
# make a copy of the history db, because it is locked when brave is open | |
let p = (mktemp -t) | |
cp $"($BRAVE)/History" $p | |
open $p | |
| query db "SELECT * from urls" | |
| sort-by last_visit_time | |
| select url title | |
} | |
def "main history" [] { | |
_history | to tsv -n | |
} | |
def "main history menu" [--query="", --filter=".", exec="echo"] { | |
^$exec ( _history | to tsv -n | rg $filter | tac | sk -q $query --reverse | from tsv -n | get column1.0 ) | |
} | |
def _bookmarks [] { | |
jq '.roots[] | recurse({parent: [.parent[]?, .name]} + .children[]? ) | select(.type == "url") ' $"($BRAVE)/Bookmarks" | |
| jq -s | |
| from json | |
| select parent name url | |
| update parent { str join "/" } | |
} | |
def "main bookmarks" [] { | |
_bookmarks | to tsv -n | |
} | |
def "main bookmarks menu" [--filter=".", --query="", exec?="echo"] { | |
^$exec (_bookmarks | to tsv -n | rg $filter | sk -q $query --reverse | from tsv -n | get column3.0) | |
} | |
def main [] { | |
help browser | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment