From ba3f688e8fd56bc1e0d1f3c73a2d16f926204b04 Mon Sep 17 00:00:00 2001 From: heymajor <13547412+heymajor@users.noreply.github.com> Date: Sat, 1 Feb 2020 16:12:30 -0500 Subject: [PATCH] Updating/expanding template explanation --- docs/recipes.md | 74 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/docs/recipes.md b/docs/recipes.md index 08e51711..b9335419 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -13,7 +13,7 @@ jrnl @alberto --tags | grep @melo And will get something like `@melo: 9`, meaning there are 9 entries where both `@alberto` and `@melo` are tagged. How does this work? First, -`jrnl @alberto` will filter the journal to only entries containing the +`jrnl @alberto` will filter the journal to only entries containing **the** tag `@alberto`, and then the `--tags` option will print out how often each tag occurred in this filtered journal. Finally, we pipe this to `grep` which will only display the line containing `@melo`. @@ -70,17 +70,61 @@ jrnlimport () { ### Using templates -Say you always want to use the same template for creating new entries. -If you have an [external editor](../advanced) set up, you can use this: +!!! note + Templates require an [external editor](../advanced) be configured. + +A template is a code snippet that makes it easier to enter use repeated text +each time a new journal entry is started. There are two ways you can utilize +templates in your entries. + +#### 1. Command line arguments + +If you had a `template.txt` file with the following contents: ```sh -jrnl < my_template.txt -jrnl -1 --edit +My Personal Journal +Title: + +Body: ``` -Another nice solution that allows you to define individual prompts comes -from [Jacobo de -Vera](https://github.com/maebert/jrnl/issues/194#issuecomment-47402869): +The `template.txt` file could be used to create a new entry with these +command line arguements: + +```sh +jrnl < template.txt # Imports template.txt as the most recent entry +jrnl -1 --edit # Opens the most recent entry in the editor +``` + +#### 2. Include the template file in `jrnl.yaml` + +A more efficient way to work with a template file is to declare the file +in your config file by changing the `template` setting from `false` to the +template file's path in double quotes: + +```sh +... +tagsymbols: "@" +template: "/path/to/template.txt" +timeformat: '%Y-%m-%d %H:%M' +version: "2.1.1" +``` + +Changes can be saved as you continue writing the journal entry and will be +logged as a new entry in the journal you specified in the original argument. + +!!! tip +To read your journal entry or to verify the entry saved, you can use this +command: `jrnl -n 1' (Check out [Import and Export](../export/#export-to-files) for more export options). + +```sh +jrnl -n 1 +``` + +### Prompts on shell reload + +If you'd like to be prompted each time you refresh your shell, you can include +this in your `.bash_profile`: ```sh function log_question() @@ -93,6 +137,11 @@ log_question 'What did I achieve today?' log_question 'What did I make progress with?' ``` +Whenever your shell is reloaded, you will be prompted to answer each of the +questions in the example above. Each answer will be logged as a separate +journal entry at the `default_hour` and `default_minute` listed in your +`jrnl.yaml` [config file](../advanced/#configuration-file). + ### Display random entry You can use this to select one title at random and then display the whole @@ -107,10 +156,11 @@ jrnl -on "$(jrnl --short | shuf -n 1 | cut -d' ' -f1,2)" ## External editors -To use external editors for writing and editing journal entries, set -them up in your `jrnl.yaml` (see `advanced usage ` for -details). Generally, after writing an entry, you will have to save and -close the file to save the changes to jrnl. +Configure your preferred external editor by updating the `editor` option +in your `jrnl.yaml` file. (See [advanced usage](../advanced) for details). + +!!! note + To save and log any entry edits, save and close the file. ### Sublime Text