Last active
June 3, 2023 23:01
-
-
Save Matts966/e9e2094bdd45cbeaa17e805b5b6c1004 to your computer and use it in GitHub Desktop.
Open all tabs in cloud tabs using sqlite3 on mac
This file contains hidden or 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
#!/bin/bash | |
if [ "$#" == 0 ]; then | |
browser=Google\ Chrome | |
elif [ "$#" == 1 ]; then | |
browser=$1 | |
else | |
echo "please pass me a browser name or run with no argument (default browser is 'Google\ Chrome')" | |
echo "e.g. './open_cloud_tabs.bash Safari'" | |
exit 1 | |
fi | |
DB_ACCESS="sqlite3 /Users/masahiromatsui/Library/Safari/CloudTabs.db" | |
QUERY="select device_name from cloud_tab_devices;" | |
DEVICE_NAME=$($DB_ACCESS <<< $QUERY | peco) | |
QUERY="select device_uuid from cloud_tab_devices where device_name = '$DEVICE_NAME';" | |
DEVICE_UUID=$($DB_ACCESS <<< $QUERY) | |
QUERY="select url from cloud_tabs where device_uuid = '$DEVICE_UUID';" | |
$DB_ACCESS <<< $QUERY | while read line; do open -a "$browser" $line; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment