Skip to content

Instantly share code, notes, and snippets.

@RyanGreenup
Last active November 3, 2020 03:06
Show Gist options
  • Save RyanGreenup/caf9ded31562364d1e0f734b1f035663 to your computer and use it in GitHub Desktop.
Save RyanGreenup/caf9ded31562364d1e0f734b1f035663 to your computer and use it in GitHub Desktop.
(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