Skip to content

Instantly share code, notes, and snippets.

@psachin
Last active December 12, 2015 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psachin/6e42d303bc54a5d38798 to your computer and use it in GitHub Desktop.
Save psachin/6e42d303bc54a5d38798 to your computer and use it in GitHub Desktop.
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