Last active
November 3, 2020 03:06
-
-
Save RyanGreenup/caf9ded31562364d1e0f734b1f035663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-insert-clipboard-png () | |
(interactive) | |
(let | |
;; Read Filename from Minibuffer | |
((filename (read-from-minibuffer "image file name: ")) | |
(directory "_media")) | |
;; Use maim to screenshot | |
(shell-command (format "mkdir -p %s/%s" default-directory directory)) | |
(shell-command (format "xclip -selection clipboard -t image/png -o > %s/%s/%s.png" default-directory directory filename )) | |
;; Insert formatted link at point | |
(save-excursion (insert(format | |
"#+attr_html: :width 400px \n #+attr_latex: :width 0.4\\textwidth \n [[file:%s/%s.png]]" | |
directory filename))) | |
;; Message success to the minibuffer | |
(message "saved to %s as %s.png" directory filename) | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment