A smart tool to help you to manage blogs
This cmdline tool was initially created to help managing my own blog, and it really saves my time. So I'd like to abstract the tool (suit for more scenario) here to benefit you! Note: the tool is only tested on macOS, but it should work on Linux as well.
pip3 install github-blogging
Enable the auto-complete feature:
echo 'eval "$(register-python-argcomplete blogging)"' >> ~/.zshrc
For the first time you use the tool, you must do some settings (e.g. set the blog project root path). To get settings done, just type:
blogging
Or you can manually create and edit the ~/.blogging
file.
Assume you just get a good idea and want to write it down to the disk. So you will create a file and name it, and write some metadata like categories and tags at first.
With this tool, you just need to type one command, and it will do all the things above (it even opens the file automatically for you):
blogging new {title} {category} {tag1} {tag2}
The writing work is almost done, but you have something more urgent to handle. You feel not very safe to only save the file on the disk. So here, a single command will save all the drafts to the cloud (GitHub):
blogging save
The urgent work is done, and you'd like to continue the writes just saved.
This tool gives you the convenience (just press tab
, and pick from all the drafts) to open the draft:
blogging continue {file_name}
The writes is done. You'd like to publish the blog to the web. To achieve this, you may need to move the file from the drafts folder to the publish folder and push the changes to the server side.
With blogging
:
blogging publish {file_name}
The blog is published, and you'd like to edit the published blog again. However, you cannot remember the exact title of the blog.
With blogging
, you can open the published blog conveniently with --filter
option. This option will search the title/category/tags of all published blogs, and pop up (need to press space
and tab
after the keyword) candidate blogs in the terminal.
blogging edit --filter {keyword} {file_name}
The --filter
is optional and is case-insensitive (i.e. 'Abc' works the same as 'abc').
Sometimes, you may need to insert images into the blog. This tool can help you to insert images into the markdown file with correct url path and also move the images to the blog git repo (which can be uploaded to GitHub later when publishing).
blogging image {image_local_path} {file_name}
This command will generate the markdown image tag and add to your clipboard. You can paste it to the markdown file directly.
Super easy, right?
All you need to do is open your terminal and execute:
pip install github-blogging
*To enable the auto-complete (press tab
) feature, you need to open a new shell session after installation.
This tool assume you have the following file structures for the blog project:
YOUR_PROJECT_PATH
βββ _drafts
βΒ Β βββ first_draft.md
βΒ Β βββ second_draft.md
βΒ Β βββ third_draft.md
βββ _posts
βΒ Β βββ first_blog.md
βΒ Β βββ second_blog.md
βΒ Β βββ third_blog.md
βββ _images
βΒ Β βββ screenshot1.png
βΒ Β βββ screenshot2.png
βββ index.html
βββ ...
All markdown files under _posts
folder will be compiled into html files and hosted on your site.
*The folder names above (e.g. _posts
) can be configured when you use the tool for the first time
The supportability of auto complete feature is depend on argcomplete.
-
Auto complete feature is not work when inputs contain unicode. (See this issue for details)(Fixed with a monkey patch) -
For zsh, it shows
command not found: complete
. To fix this, pls add following lines to your~/.zshrc
file and source it:autoload bashcompinit bashcompinit
Support more shell typesMore flexible blog project structure (e.g. can customise the draft/publish folder name)An option to open and edit published blogs, also support add-filter
option to filter by word, category, tags, etc.Add a gif screenshot to show this tool- Cache the blogs' meta info to improve performance (For now, I have near 80 blogs, performance is not the bottleneck)