41 lines
1.4 KiB
Bash
Executable file
41 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Interactively select (in fzf) an url from Firefox/Chrome/Chromium history to
|
|
# open in your browser (depends on $BROWSER). Should work on Linux and MacOS.
|
|
#
|
|
# requires: sqlite3
|
|
|
|
sep='{{::}}'
|
|
[[ $OSTYPE == linux* ]] && open='xdg-open' || open='open'
|
|
|
|
_do_fzf() {
|
|
for url in $(awk -F "$sep" '{printf "%s, %s\n", $1, $2}' | gui-fzf --multi | sed 's#.*\(https*://\)#\1#'); do
|
|
$open "$url" &
|
|
done
|
|
}
|
|
|
|
case ${BROWSER:-firefox} in
|
|
firefox)
|
|
for dir in ~/.mozilla/firefox/*.default ~/Library/Application\ Support/Firefox/Profiles/*.default; do
|
|
if [[ -d "$dir" ]]; then
|
|
sqlite3 -separator $sep "$dir/places.sqlite" \
|
|
"SELECT DISTINCT title, url FROM moz_places \
|
|
WHERE title IS NOT NULL \
|
|
ORDER BY last_visit_date DESC" | _do_fzf
|
|
break
|
|
fi
|
|
done
|
|
;;
|
|
*)
|
|
for dir in ~/.config/google-chrome/Default ~/.config/chromium/Default ~/Library/Application\ Support/Google/Chrome/Default; do
|
|
if [[ -f "$dir/History" ]]; then
|
|
cp -f "$dir/History" "/tmp/_h"
|
|
sqlite3 -separator $sep "/tmp/_h" \
|
|
"SELECT substr(title, 1, $((COLUMNS / 3))), url \
|
|
FROM urls ORDER BY last_visit_time DESC" | _do_fzf
|
|
break
|
|
fi
|
|
done
|
|
;;
|
|
esac
|