Emacs - make a screenshot and insert a link to it.


This tiny snippet enhances note taking in Emacs. This command takes a screenshot with a program called scrot, prompts for a name for it and places it in a directory under the user's org-directory. Feel free to tailor it to your needs.

(defvar org-shot-link-dir
  (let ((dirname (concat (file-name-as-directory org-directory)
	(unless (file-exists-p dirname)
	 (mkdir dirname))

(defun org-shot-link (name)
  "Make a named screenshot and paste the link to it at point."
  (interactive "sName the org screenshot: ")
  (let ((default-directory org-shot-link-dir))
	(start-process-shell-command "org-shot"
							   (format "scrot --select \"%s.png\"" name)))
  (insert (format "[[file:pics/%s.png]]" name)))


Created: 2022-02-12 Сб 12:25