Skip to content

Instantly share code, notes, and snippets.

@thash
Created June 29, 2015 23:37
Show Gist options
  • Save thash/865c36bb5c03786213c6 to your computer and use it in GitHub Desktop.
Save thash/865c36bb5c03786213c6 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/zsh
sqlite_file="$(find $HOME/Library/Application\ Support/Firefox/Profiles/*.default/places.sqlite)"
if [ ! -e "$sqlite_file" ]; then
echo "cannot find sqlite file"; return
fi
sql="SELECT b.title, p.url FROM moz_bookmarks as b, moz_places as p \
WHERE b.type = 1 \
AND b.title IS NOT NULL \
AND b.fk = p.id \
AND p.url NOT LIKE 'place:%' \
ORDER BY b.lastModified;"
# placeの方がちゃんとしたURLかどうか見ないとフォルダかbookmarkかわからん
sql="SELECT b.fk FROM moz_bookmarks as b, moz_places as p \
WHERE b.type = 1 \
AND b.title IS NOT NULL \
AND b.fk = p.id \
AND p.url NOT LIKE 'place:%';"
sql="SELECT b.fk FROM moz_bookmarks as b, moz_places as p \
WHERE b.type = 1 \
AND b.title IS NOT NULL \
AND b.fk = p.id \
AND p.url NOT LIKE 'place:%' \
ORDER BY b.lastModified;"
# fks="$(sqlite3 $sqlite_file "$sql" | tr '\n' ' ')"
for fk in `sqlite3 $sqlite_file "$sql"`
do
sql="SELECT * FROM moz_bookmarks as b \
WHERE b.fk = $fk \
AND title IS NULL;"
sqlite3 $sqlite_file "$sql"
echo "---"
done
# sqlite3 $sqlite_file "$sql"
# selections="$(sqlite3 $sqlite_file "$sql" | fzf --multi)"
# if [ "$selections" = "" ]; then; return; fi
#
# echo $selections
# echo $selections | awk -F '|' '{print $(NF)}' | xargs open -a Firefox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment