Browse Brave Browser History

Interactively browse Brave Beta history from terminal using fzf

Terminal showing fzf fuzzy-searching Brave browser history

I wrote a small shell function that lets me browse my Brave Browser (Beta) history directly from the terminal, using fzf for interactive searching. This is similar to browsing Chrome history, but for Brave Beta.

The Function

brave-beta-history
brave-beta-history() {
local cols sep brave_history open
cols=$(( COLUMNS / 3 ))
sep='{::}'
if [ "$(uname)" = "Darwin" ]; then
brave_history="$HOME/Library/Application Support/BraveSoftware/Brave-Browser-Beta/Default/History"
open=open
else
brave_history="$HOME/.config/BraveSoftware/Brave-Browser-Beta/Default/History"
open=xdg-open
fi
cp -f "$brave_history" /tmp/bh
sqlite3 -separator $sep /tmp/bh \
"select substr(title, 1, $cols), url
from urls order by last_visit_time desc" |
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
}