Last active
December 18, 2022 22:19
-
-
Save Gavinok/7dfa5569c1b706095b05c4a0aa934085 to your computer and use it in GitHub Desktop.
Create a gist from a given region interactively. Depends on the `gh` command line interface
This file contains hidden or 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 gist-from-region (BEG END fname desc &optional private) | |
"Collect the current region creating a github gist with the | |
filename FNAME and description DESC. | |
If the opitonal argument PRIVATE is non-nil then the gist will be | |
made private. Otherwise the gist will be default to public" | |
(interactive (list (mark) (point) | |
(read-string "File Name: ") | |
(read-string "Description: ") | |
current-prefix-arg)) | |
(let ((fname-arg (concat "--filename " fname)) | |
(desc-arg (concat "--desc " (shell-quote-argument desc))) | |
(private-arg (if private | |
"--public" | |
""))) | |
(shell-command-on-region BEG END (format "gh gist create %s %s %s -" | |
fname-arg | |
desc-arg | |
private-arg)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment