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

Overview

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)
						 "pics")))
	(unless (file-exists-p dirname)
	 (mkdir dirname))
	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"
							   nil
							   (format "scrot --select \"%s.png\"" name)))
  (insert (format "[[file:pics/%s.png]]" name)))

Resources

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