本教程首发于我的博客(GitHub 图床教程)
安装所需软件:
sudo apt install fzf xclip
pip3 install pyperclip
一键上传脚本:
#!/bin/bash
git add --all
git commit -m "update"
git push
获取图片地址脚本:
#!/usr/bin/env python3
import pyperclip
import subprocess
# 请按照实际情况填写
username = "username"
repo_name = "repo-name"
branch_name = "branch-name"
github = f"https://raw.githubusercontent.com/{username}/{repo_name}/{branch_name}/"
jsdeliver = f"https://cdn.jsdelivr.net/gh/{username}/{repo_name}/"
copy_path = "fzf | tr -d '\n' | xclip -selection c"
def get_url():
subprocess.call(copy_path, shell=True)
path = pyperclip.paste()
print(f"\n![]({github+path})\n")
print(f"![]({jsdeliver+path})\n")
pyperclip.copy(f"![]({jsdeliver+path})")
while True:
if input("Press Enter to continue. Type something else to quit: ") == "":
get_url()
else:
break
这个脚本使用会输出图片的原网址和经过 jsDelivr 加速的网址,并把 jsDelivr 的网址复制到剪贴板。