gist制作脚本
项目描述
示例
# post a secret gist on public github: cat doge | gister # post a secret gist on private github deployment: cat doge | gister -p # post a secret anonymous gist on public github: cat doge | gister -a # post a secret anonymous gist on private github deployment: cat doge | gister -ap # post a secret gist on public github with a command: cat doge | tail -n4 | gister -c "cat doge | tail -n4" # post a secret gist of a file on public github: gister filename.txt # post a secret gist of two files on public github: gister lolcats doge.text # post a secret anonymous gist of globbed files on public github: gister -a *.txt *.py gister -a ~/home/whatever/* # post an ipython notebook secret gist on public github which is now formatted \o/: gister ~/.ipython/notebooks/cool_notebook.ipynb gister ~/.ipython/notebooks/* # edit a gist gister file.txt * edit file.txt * gister -e o4j208j20fj20f3j file1.txt # add a new file gister -e o4j208j20fj20f3j file2.txt
使用方法
注意!现在所有gist都是保密的
usage: gister [-h] [-a] [-c COMMAND] [-d DESCRIPTION] [-e id/url] [-p] [-v] [files [files ...]] make gists! positional arguments: files name of file(s) to gist optional arguments: -h, --help show this help message and exit -a, --anonymous gist will be anonymous even if you have oauth configured -c COMMAND, --command COMMAND command to prepend to gist -d DESCRIPTION, --description DESCRIPTION description of the gist -e id/url, --edit id/url edit a gist identified by id or url -p, --private put gist on configured enterprise github -v, --vim gist came from vim, no prompt/history
使用方法 - 编辑gist
编辑gist的工作方式如下: * 使用 -e 标志标记的任何文件将被添加到gist中,除非该名称的文件已经在gist中存在,在这种情况下,它将被当前文件的内容覆盖 * 将内容通过管道传输到gist(例如 echo wahoo | gister)将始终将原始命令的输出存储在名为 gistfile1.txt 的文件中。如果您通过将新内容传输到gist来编辑它,则之前的gistfile1.txt将被覆盖 * 使用gister无法删除gist中的某些文件 * 如果使用 -e 标志调用gister并显示nbviewer url,则将在url后附加 ?flush_cache=true
使用方法 - ipython笔记本
ipython笔记本是扩展名为 .ipynb 的文件。如果命令行上指定的所有文件都具有此扩展名,则将生成一个指向 http://nbviewer.ipython.org url的链接来显示您的gist。nbviewer不会永久存储您的gist数据,但会将其缓存约10分钟
请注意,使用 -p/--private 标志时不会生成nbviewer url,因为它无法访问gist
安装
pip install gister 或克隆仓库并 python setup.py install
如果您收到 InsecurePlatformWarning,请使用 pip install requests[security] 解决它。我必须在Fedora 21系统上安装libffi-devel才能让pyOpenSSL正常运行
配置文件 - .gister
提供了一份示例配置文件 .gister 供您使用。它将在 ~/.gister 中查找。它支持以下值
public_oauth - 您的公开 GitHub OAuth 令牌(匿名 Gist 不需要)
private_oauth - 您的私有 GitHub OAuth 令牌(如果您计划使用私有 GitHub)(匿名 Gist 不需要)
prompt - 当使用 -c/--command 选项时显示的提示
public_github_url - 默认为公开 GitHub 的 URL
private_github_url - 如果您计划使用 -p/--private,则需要将此 URL 设置为您私有 GitHub 部署的位置
GitHub OAuth 令牌
gister 可以不使用 OAuth 令牌使用,但可以通过指定 -a 或 --anonymous 标志来创建匿名 Gist
如果您未为使用的端点配置 OAuth,所有 Gist 都将回退到匿名发布
您可以通过访问您的账户设置中的 applications 来管理您的 GitHub OAuth 令牌
您也可以使用 GitHub API 创建 OAuth 令牌,就像我在这个 gist 中做的那样
keyring
使用 keyring 是可选的。它允许您将 OAuth 令牌存储在比 ~/.gister 配置文件更安全的地方
如果您希望使用 keyring,请按如下方式指定您的 public_oauth 和/或 private_oauth 令牌
[gister] private_oauth = KEYRING public_oauth = KEYRING
gister 将查找一个名为 gister 的部分,其中包含 public_oauth 和/或 private_oauth 键,包含与您的公开 GitHub 和/或私有 GitHub 账户关联的 GitHub OAuth 令牌。添加到 Python keyring 的 示例
与 vim 一起使用
我把我添加到了 我的 .vimrc 中,以与 gister 交互
" ------- gist making! -------------------------------- fun Gister(...) let gister_call = "gister -v" for flag in a:000 let gister_call = gister_call . " " . flag endfor let result = system(gister_call, expand("%:t") . "\n" . getreg("\"")) echo result endfun " secret gist on public github from selection or single line vnoremap <F9> y:call Gister()<cr> nnoremap <F9> yy:call Gister()<cr> " secret gist on private github from selection or single line vnoremap <F10> y:call Gister("-p")<cr> nnoremap <F10> yy:call Gister("-p")<cr> " ------- end pastie.org ---------------------------
项目详情
gister-1.0.23.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | dd0a1e9ed336d85a6d32520d8738c99cd840e13b6b6de4a010d0ac38780a680e |
|
MD5 | 3de53e8e6016c8eb90ff7bc1fb31386d |
|
BLAKE2b-256 | 84572d891596d0950b84f61632887ee88986c62ae316682456062dc23e78a8c9 |