github-gist

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub Gist Publisher

GitHub Gist 发布工具

Publish any file as a GitHub Gist for easy sharing.
将任意文件发布为GitHub Gist,便于分享。

Prerequisites

前置条件

Uses
gh
CLI by default. Ensure you're authenticated:
bash
gh auth status
默认使用
gh
CLI工具。请确保已完成身份验证:
bash
gh auth status

If not authenticated: gh auth login

如果未验证:gh auth login


Fallback: Set `GITHUB_GIST_TOKEN` env var with gist scope.

备选方案:设置带有gist权限的`GITHUB_GIST_TOKEN`环境变量。

Usage

使用方法

bash
undefined
bash
undefined

Publish file as secret (unlisted) gist - DEFAULT

将文件发布为私密(未列出)Gist - 默认设置

python3 scripts/publish_gist.py /path/to/file.md
python3 scripts/publish_gist.py /path/to/file.md

Publish as public gist (visible in your profile)

将文件发布为公开Gist(会显示在你的个人主页中)

python3 scripts/publish_gist.py /path/to/file.md --public
python3 scripts/publish_gist.py /path/to/file.md --public

Custom description

自定义描述

python3 scripts/publish_gist.py /path/to/file.md -d "My awesome note"
python3 scripts/publish_gist.py /path/to/file.md -d "我的精彩笔记"

Override filename in gist

覆盖Gist中的文件名

python3 scripts/publish_gist.py /path/to/file.md -f "readme.md"
python3 scripts/publish_gist.py /path/to/file.md -f "readme.md"

From stdin

从标准输入读取内容

echo "Hello" | python3 scripts/publish_gist.py - -f "hello.txt"
echo "Hello" | python3 scripts/publish_gist.py - -f "hello.txt"

Just get URL

仅获取链接

python3 scripts/publish_gist.py /path/to/file.md --url-only
python3 scripts/publish_gist.py /path/to/file.md --url-only

Create and open in browser

创建后在浏览器中打开

python3 scripts/publish_gist.py /path/to/file.md --open
undefined
python3 scripts/publish_gist.py /path/to/file.md --open
undefined

Options

可选参数

FlagDescription
--public
Create public gist (default is secret/unlisted)
-d, --description
Gist description
-f, --filename
Override filename
--url-only
Output only URL
--open
Open in browser
--api
Force API instead of gh CLI
标识描述
--public
创建公开Gist(默认是私密/未列出)
-d, --description
Gist描述
-f, --filename
覆盖文件名
--url-only
仅输出链接
--open
在浏览器中打开
--api
强制使用API而非gh CLI

Output

输出示例

json
{
  "url": "https://gist.github.com/user/abc123",
  "id": "abc123",
  "public": false,
  "filename": "file.md"
}
json
{
  "url": "https://gist.github.com/user/abc123",
  "id": "abc123",
  "public": false,
  "filename": "file.md"
}

Example

示例