从github gists更新本地和远程文件的cli

getgist的Python项目详细描述


https://img.shields.io/travis/cuducos/getgist.svg?style=flathttps://img.shields.io/coveralls/cuducos/getgist.svg?style=flathttps://img.shields.io/codeclimate/maintainability-percentage/cuducos/getgist.svghttps://img.shields.io/pypi/v/getgist.svg?style=flathttps://img.shields.io/pypi/pyversions/getgist.svg?style=flat

获取要点

使用one single commandGitHub Gist轻松下载任何文件。

为什么?

由于种种原因,我没有dotfiles存储库。我更喜欢 将我的.vimrc.gitconfig.bash_profile等存储为 Gists

我编写这个脚本是为了用一个 例如,命令:getmy .vimrc就完成了。

安装

$ pip install getgist

getgist与python 2.7+或3.4+一起使用。

update只需运行$ pip install -U getgist

使用量

从github获取gists

只要运行getgist <username> <filename>。例如:

$ getgist cuducos .vimrc
  Fetching https://api.github.com/users/cuducos/gists
  Reading https://gist.githubusercontent.com/cuducos/409fac6ac23bf515f495/raw/666d7d01a0058e4fd898ff752db66160f10a60bb/.vimrc
  Saving .vimrc
  Done!

getgist询问当一个本地文件(同名)时该怎么办 存在。如果您决定不删除文件的本地副本,它将 使用诸如.bkp.bkp1.bkp2等扩展名重命名。

更新github上的gist

只需运行putgist <username> <filename>即可升级远程gist 本地文件的内容。它需要一个oauth令牌(参见使用 OAuth认证如下)。例如:

$ putgist cuducos .vimrc
  User cuducos authenticated
  Fetching https://api.github.com/gists
  Sending contents of .vimrc to https://api.github.com/gists/409fac6ac23bf515f495
  Done!
  The URL to this Gist is: https://gist.github.com/cuducos/409fac6ac23bf515f495

getgist询问当它在 在不同的gist中使用相同的名称。

使用OAuth身份验证

为什么?

添加您的personal access token 作为允许的环境变量:

  1. 私人注册表的下载
  2. 现有GISTs
  3. 的更新
如何做到?
  1. 获取具有管理gists权限的个人访问令牌 从GitHub settings
  2. 使用 个人访问令牌

示例

$exportGETGIST_TOKEN=whatever1234
$ getgist cuducos .vimrc
  User cuducos authenticated
  Fetching https://api.github.com/gists
  Reading https://gist.githubusercontent.com/cuducos/409fac6ac23bf515f495/raw/666d7d01a0058e4fd898ff752db66160f10a60bb/.vimrc
  Saving .vimrc
  Done!
  The URL to this Gist is: https://gist.github.com/cuducos/409fac6ac23bf515f495

即使您尝试下载的文件是私有文件,也可以执行此操作 gist(当然用户名必须是GETGIST_TOKEN帐户)。

设置默认用户

为什么?

设置默认用户以避免一直键入您的github用户名

如何做到?
  1. 使用github设置名为GETGIST_USER的环境变量 用户名
  2. 使用快捷方式getmy <filename>putmy <filename>

示例

$exportGETGIST_USER=cuducos
$ getmy .vimrc
  Fetching https://api.github.com/users/cuducos/gists
  Reading https://gist.githubusercontent.com/cuducos/409fac6ac23bf515f495/raw/666d7d01a0058e4fd898ff752db66160f10a60bb/.vimrc
  Saving .vimrc
  Done!
  The URL to this Gist is: https://gist.github.com/cuducos/409fac6ac23bf515f495

贡献

请随意使用report an issueopen a pull requestdrop a line

非常感谢@ddboline/u/Sean1708感谢你的贡献!

不要忘记用Black格式化代码,并编写和运行测试:

$ pip install tox
$ tox

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java iBatis加载对象列表   Eclipse中的javajboss调试   java Junit@AfterClass(非静态)   java如何用JAXR捕捉WebApplicationException   java Bloom着色器性能   java如何使活动保持活动状态,并每秒通知和运行   Java:是否替换ArrayList中不允许的ArrayList cos基元类型?   java Android Studio,使用PHP数据库文件中的GET用4个随机元素填充列表视图   java Antisamy 1.5.3跨度标记样式属性异常   java在构造函数调用之前或之后通过声明初始化类DS字段?   java从地址中删除重复字   java如何列出FloydWarshall算法中传递的顶点   java如何从不同的文件加载基于springboot的REST应用程序属性?   java HttpSession Url重写无法使用servlet技术正常工作   java为什么在代码中出现“无法创建组件”错误?