Add dwim-shell-command to upload files to 0x0.st
This commit is contained in:
parent
1f0b56cc5a
commit
31ac3363da
27
gists.org
27
gists.org
|
@ -496,7 +496,7 @@ It turns out it didn't work as well as I hoped, paredit steals the RET binding s
|
|||
(advice-add #'tempel-insert :around #'my/store-region)
|
||||
#+end_src
|
||||
|
||||
* dwim-shell-command to encrypt files with age :emacs:age:
|
||||
* dwim-shell-command to encrypt files with age :emacs:age:dwim_shell_command:
|
||||
|
||||
#+begin_src elisp :tangle gists/dwim-shell-command-encrypt-with-age.el
|
||||
(defconst my/cygwin-p (string-equal system-type "cygwin"))
|
||||
|
@ -527,6 +527,31 @@ It turns out it didn't work as well as I hoped, paredit steals the RET binding s
|
|||
:post-process-template #'my/dwim-shell-command/convert-path-cygwin))
|
||||
#+end_src
|
||||
|
||||
* dwim-shell-command to upload files to 0x0 :emacs:dwim_shell_command:
|
||||
|
||||
#+begin_src elisp :tangle gists/dwim-0x0-upload.el
|
||||
(defun my/dwim-shell-command/0x0-upload ()
|
||||
"Upload the marked files to 0x0.st"
|
||||
(interactive)
|
||||
(let ((url "https://0x0.st"))
|
||||
(dwim-shell-command-on-marked-files
|
||||
"0x0 upload"
|
||||
(format "curl -Ffile=@<<f>> -Fsecret= %s" url)
|
||||
:utils "curl"
|
||||
:post-process-template
|
||||
;; Insert the single quotes at the appropriate place according to
|
||||
;; 0x0.st example online:
|
||||
;; curl -F'file=@yourfile.png' -Fsecret= https://0x0.st
|
||||
;;
|
||||
;; The placement of these single quotes confuse the escaping
|
||||
;; mechanisms of dwim-shell-command, as it considers @ as the
|
||||
;; opening 'quote' as it appears right in front of <<f>>.
|
||||
(lambda (template path)
|
||||
(string-replace "-Ffile" "-F'file"
|
||||
(string-replace path (concat path "'") template))))))
|
||||
#+end_src
|
||||
|
||||
|
||||
* Apply maybe
|
||||
|
||||
#+begin_src elisp :tangle gists/apply-maybe.el
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
(defun my/dwim-shell-command/0x0-upload ()
|
||||
"Upload the marked files to 0x0.st"
|
||||
(interactive)
|
||||
(let ((url "https://0x0.st"))
|
||||
(dwim-shell-command-on-marked-files
|
||||
"0x0 upload"
|
||||
(format "curl -Ffile=@<<f>> -Fsecret= %s" url)
|
||||
:utils "curl"
|
||||
:post-process-template
|
||||
;; Insert the single quotes at the appropriate place according to
|
||||
;; 0x0.st example online:
|
||||
;; curl -F'file=@yourfile.png' -Fsecret= https://0x0.st
|
||||
;;
|
||||
;; The placement of these single quotes confuse the escaping
|
||||
;; mechanisms of dwim-shell-command, as it considers @ as the
|
||||
;; opening 'quote' as it appears right in front of <<f>>.
|
||||
(lambda (template path)
|
||||
(string-replace "-Ffile" "-F'file"
|
||||
(string-replace path (concat path "'") template))))))
|
Loading…
Reference in New Issue