Typora - 如何快速提交笔记到 Git
1、背景
- 作为「只用 Markdown 撰写笔记、文档的程序猿」,在试用了多款 MD 编辑器后,最终还是选择了 Typora
- 为了实现笔记的「历史版本」,我在 笔记的根路径,通过
git init/add/commit
,进行本地的提交 - 为了实现「云笔记」,便把上述
git 库
提交到了GitHub
—— 于是我就在想:“如何能快速提交笔记到 Git”?
2、实现
2.1、双击执行 push.command
我编写了如下 shell
脚本,并保存为 push.command
文件,之后即可实现「双击执行该文件」以提交指定路径下的变动
bash
1 |
|
执行效果如下:
2.2、Typora 的自定义导出
偶然间,看到了 Typora 官网的一篇文章,发现其「导出」功能可以执行自定义命令,还给了 git commit
的示例:
Other Formats Using Custom Commands
You can also add export options based on command line commands. You will need to config:
Command
The command you want to trigger for this export option. For example, to submit current file to git server, you can use
git add "${currentPath}" && git commit -m "save" && git push
.
上述示例,仅是「提交当前文件」,但通常 我们是想提交所有变更,所以可以改成如下命令:
bash
1 | # 获取当前 git 库的根路径,并将其下的所有变更添加、提交,最后 push 到远端 |
执行效果如下:
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Hyper Tech!
评论