Last active
November 1, 2019 15:52
-
-
Save Matts966/5eb882beb86ef25dd8ac209e2d9c4636 to your computer and use it in GitHub Desktop.
Copy all tabs of some applications to others
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 [ "$#" -ne 2 ]; then | |
| echo "please pass me 2 application names" | |
| echo "e.g. './copy_tabs.bash Safari Google\ Chrome'" | |
| exit 1 | |
| fi | |
| from_browser=$1 | |
| to_browser=$2 | |
| osascript <<EOF | while read line; do open -a "$to_browser" $line; done | |
| set urls to "" | |
| tell application "$from_browser" | |
| set window_list to every window | |
| repeat with the_window in window_list | |
| set tab_list to every tab in the_window | |
| repeat with the_tab in tab_list | |
| set urls to urls & URL of the_tab & "\n" | |
| end repeat | |
| end repeat | |
| end tell | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment