Skip to content

Instantly share code, notes, and snippets.

@glallen01
Last active October 28, 2022 00:31
Show Gist options
  • Save glallen01/5e7602e5f4972c49fd9e8bf4cb0d19ee to your computer and use it in GitHub Desktop.
Save glallen01/5e7602e5f4972c49fd9e8bf4cb0d19ee to your computer and use it in GitHub Desktop.
get tab urls from chrome into org-mode with applescript
(defun gla/chrome-tabs-to-org ()
(interactive)
;; adopted from applescript found here: https://pastebin.com/AXDtWJKL
(let* ((osascript-urls (do-applescript "
tell application \"Google Chrome\"
set allUrls to {}
repeat with theWindow in every window
set urlsInWindow to {}
repeat with theTab in every tab of theWindow
set currentUrl to the theTab\'s URL
set urlsInWindow to urlsInWindow & {currentUrl}
end repeat
set allUrls to allUrls & {urlsInWindow}
end repeat
end tell
"))
(urls (split-string (replace-regexp-in-string "[\"{}]+" "" osascript-urls) ", ")))
(insert (mapconcat (lambda (x) (format "- [[%s]]\n" x)) urls ""))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment