write
The write command initiates a series of actions that are commonly performed when you edit your site content. It runs the edit , preview , and watch commands simultaneously. This does the following:
- Opens your Markdown file in the $OCEDITOR text editor
- Starts a local server at port 8000
- Watches your site directory for SASS/CSS and Markdown file changes
If you do not want to perform all of these commands simultaneously, you can manually perform any of the actions with the respective command.
The write command opens a Markdown file (or multiple files) in the source/_posts path using a filename substring search with the find command. Enter the Markdown post filename substring as the argument for your command. This argument can be a date because every Markdown filename includes the date of origin in the filename. See the find command documentation for additional details and examples.
Your default text editor is defined as a shell variable ($OCEDITOR) in your shell startup file. You can find more information about how to do this here. Commands for several of the most common/popular text editors are available as options and do not require you to modify your shell startup file. See the Options section below for details.
Usage
oc write <post filename substring>
Arguments
Argument | Description |
---|---|
post filename substring | a substring in the Markdown filename |
Options
Option | Description |
---|---|
--emacs | open the emacs text editor |
--lp | open the LightPaper text editor |
--mate | open the Text Mate text editor |
--mou | open the Mou text editor |
--sublime | open the Sublime Text editor |
--vim | open the vim text editor |
Examples
Edit a Post with Default Editor that Contains the Substring "super-cool-post"
oc write "super-cool-post"
Edit a Post with Default Editor that was Generated on August 30, 2013
oc write 2013-08-30
Edit a Post with Emacs
oc write --emacs 2013-08-30
Edit a Post with LightPaper
oc write --lp 2013-08-30
Edit a Post with Sublime Text
oc write --sublime 2013-08-30
Edit a Post with Text Mate
oc write --mate 2013-08-30
Edit a Post with Mou
oc write --mou 2013-08-30
Edit a Post with Vim
oc write --vim 2013-08-30
Additional Notes
The write command opens a local server at port 8000. You can view your site at http://localhost:8000. If you would like to use a different port, you (currently) need to run each of the included commands manually. See the preview command documentation for more information on how to change the port.
You do not need to run the generate command to make new static site files after you edit the Markdown or SCSS/CSS files. This occurs automatically. Just reload your browser to see the changes after you save the files.