原文请访问我的博客:http://www.quippy.tech
Sublime是一款强大优雅的编辑器,便捷、轻量、启动快、可扩展性强。Hexo作为个人博客搭建利器,具备简洁、优雅、扩展性强的特点。本文主要解决的问题:联袂Sublime和Hexo,整合出一个简单高效的博客发布工具。一次性配置Sublime,无需命令行,用Sublime优雅的写Hexo博客。
命令创建的路径 Sublime >> Tools >> Build System >> New Build System…,新建以下内容:
{
"shell_cmd": "title=\\$(date +%H%M%S) && hexo new \\$title && subl /Users/mac/Documents/blog/source/_posts/\\$title.md",
"working_dir": "/Users/mac/Documents/blog/",
"path": "/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"
}
另存为 hexo-new-blog.sublime-build
默认博客文件和文件名为title.md,需要通过下面所设的快捷键F2进行重命名。
注意:需要结合自己本地的blog目录和Sublime安装目录进行配置shell_cmd和path。
命令创建的路径 Sublime >> Tools >> Build System >> New Build System…,新建以下内容:
{
"shell_cmd": "ps -ef|grep hexo|grep -v grep|awk '{print \"kill -9 \"\\$2}'|sh && hexo clean && hexo s",
"working_dir": "/Users/mac/Documents/blog/"
}
另存为 hexo-start.sublime-build
命令创建的路径 Sublime>>Tools>>Build System>>New Build System…,新建以下内容:
{
"shell_cmd": "hexo clean&&hexo g -d",
"working_dir": "/Users/mac/Documents/blog/"
}
另存为 hexo-deploy.sublime-build
打开包目录:Sublime >> Preferences >> Browser Packages…
# rename_file.py
import sublime
import sublime_plugin
import os
import functools
class RenameFileCommand(sublime_plugin.WindowCommand):
def run(self, paths):
if paths[0] == "$file":
paths[0] = self.window.active_view().file_name()
branch, leaf = os.path.split(paths[0])
v = self.window.show_input_panel("New Name:", leaf, functools.partial(self.on_done, paths[0], branch), None, None)
name, ext = os.path.splitext(leaf)
v.sel().clear()
v.sel().add(sublime.Region(0, len(name)))
def on_done(self, old, branch, leaf):
new = os.path.join(branch, leaf)
try:
os.rename(old, new)
v = self.window.find_open_file(old)
if v:
v.retarget(new)
except:
sublime.status_message("Unable to rename")
def is_visible(self, paths):
return len(paths) == 1
感谢 https://superuser.com/questions/683766/renaming-open-files-in-sublime-text-2/684114#684114
打开快捷键设置 Sublime >> Preferences >> key Bindings,添加下面配置:
[
{
"keys": ["f2"], "command": "rename_file", "args": { "paths": ["$file"] }
}
]
也可使用命令来控制文件的重命名和删除,Command-Shift-P >> Package Control: Install Package >> File Rename 和 Delete Current File。
Command-Shift-P 打开Package Control,Install Package
搜索并安装 Markdown Editing即可。
默认MarkdownLivePreview不开启实时预览,可设置
Preferences → Package Settings → MarkdownLivePreview → Setting,打开后将左边default的设置代码复制到右边User栏,找到”markdown_live_preview_on_open”:false,把false改为true
Markdown Editing本身已很好用,不建议再次安装MarkdownLivePreview。
感谢 https://www.cnblogs.com/itbull/p/6182460.html
更多原创请访问:http://www.quippy.tech