Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Take screeeshot from Emacs
(defun screenshot-frame ()
"Take screenshot.
Default image ~/screenshots/TIMESTAMP.png
Usage:
M-x screenshot-frame
Enter custom-name or RET to save image with timestamp"
(interactive)
(let* ((insert-default-directory t)
(screenshots-dir "~/screenshots/")
(sframe-name (concat (format-time-string "%d-%b-%Y-%T") ".png"))
(sframe-full-path
(read-file-name "Screenshot name: " screenshots-dir
(concat screenshots-dir sframe-name))))
(if (not (file-accessible-directory-p screenshots-dir))
(make-directory-internal screenshots-dir))
(shell-command-to-string
(concat "import " sframe-full-path))
(message "Screenshot saved as %s" sframe-full-path)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment