Skip to content

Instantly share code, notes, and snippets.

@Matts966
Last active November 1, 2019 15:52
Show Gist options
  • Select an option

  • Save Matts966/5eb882beb86ef25dd8ac209e2d9c4636 to your computer and use it in GitHub Desktop.

Select an option

Save Matts966/5eb882beb86ef25dd8ac209e2d9c4636 to your computer and use it in GitHub Desktop.
Copy all tabs of some applications to others
#!/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