~eidolon/journal.sh

Simple journal management script.
Added tags find with support for exact and fuzzy match.
Added support for some tags operations and opening the previous day as a default behavior.
Added functions to show the unique tags present in journal entries.

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~eidolon/journal.sh
read/write
git@git.sr.ht:~eidolon/journal.sh

You can also use your local clone with git send-email.

#journal.sh

Script for journal management. Pairs with journal.nvim.

#Usage

Usage: journal.sh [-t|--template <template>] [-s|--suffix <suffix>]
                  [-r|--root <dir>] [-tr|--template-root <dir>]
                  [-nc|--no-color] [--ns|--no-suffix] [-h|--help]
                  [<command> [sub-command|args]]

Manage journal entries.

Commands:
  <no args>           Edit today (and open yesterday if it exists)
  t|today             Edit today (this is the default no-args behavior).
  c|commit            Commit/push any changes to git.
  n|new-journal <dir> Create a new journal with the specified directory.
  tags <sub-command>  Operate on the tags of the current journal.
                      Use "--help tags" for more information.

Arguments:
  -t|--template <name>      Choose the template to use for new entries (default=template).
  -s|--suffix <choice>      Set the journal file suffix (default=".md"). The dot is required.
  -r|--root <dir>           Set the journal root directory (default=entries). Should not end in a slash.
  -tr|--template-root <dir> Set the template root directory (default=templates). Should not end in a slash.
  -nc|--no-color            Disable colored output.
  -ns|--no-suffix           Do not use any suffix.
  --git-upstream <value>    Set the git upstream, only relevant for the commit command.
  --git-branch <value>      Set the git branch, only relevant for the commit command.
  -h|--help [topic]         Display this usage text, or help for a particular topic.

Please note that default values for most arguments can be configured in journal.config.

All edit commands open journal entries in your $EDITOR. Please ensure
the $EDITOR environment variable is set.

Examples:

Edit today: $ journal.sh
Edit today: $ journal.sh today
Commit journal changes: $ journal.sh commit
Create a new journal: $ journal.sh n my-journal

#Feature Overview

  • [✓] Easily create new journal entries.
  • [✓] Git support:
    • [✓] Automatically commit new journal content.
  • [✓] Suffix support
    • [✓] Support Markdown files by default (.md)
    • [✓] Support for changing suffix.
  • [✓] Template file support.
    • [✓] Support replacements within new journal files.
  • [✓] Command to initialize a new journal.
  • [✓] Configuration/project file for journals.
  • [x] Stats:
    • [x] Word count (by day, month, year, all time)
    • [x] Number of journal entries (by month, year, all time)
  • [x] Tag support
    • [✓] Show unique tags
    • [x] Show all notes for a given tag
    • [✓] Show occurrence counts for each tag
  • [x] Mental and physical health tracking support.

#Installation

Just place the script journal.sh into your $PATH somehow. An easy way to do this is to add ~/bin to your $PATH and add/link this script there.

This repository provides an installation helper, install.sh:

#Install to ~/bin/journal.sh

$ ./install.sh

#Install to ~/bin/,j

Some people like using a comma to denote custom scripts.

$ ./install.sh -c

#Install to a custom script name

$ ./install.sh -n "my_name"

#Journal Layout

The default journal layout looks like the following:

+ my-journal/
    + entries/
        + 2021/
            + December
                - 01.md
                - 02.md
        + 2022/
            + July
                - 23.md
                - 24.md
                - 25.md
    + templates/
        - template.md
  • There is a root directory for journal entries. By default, this directory is called entries.
  • There is a root directory for templates. By default, this directory is called templates.
  • Journal entries are organized into directories for each year, and each month within a year.
  • Journal entries have file names of the day-of-month with some suffix depending on file type. The suffix can be omitted.

#Templates

journal.sh supports template files where are used to create new notes. There are a few relevant command line settings:

  • -t|--template: Sets the template that will be used. The default is template. This means that when creating a new note (e.g. in journal.sh today), the script will look for templates/template.md by default.
  • -s|--suffix: Sets the suffix that will be used. The default is md for Markdown documents. This impacts the format of the new note and also what template is used. If this is changed to, for example, txt, journal.sh today will look for templates/template.txt.
  • -tr|--template-root: Sets the directory where journal.sh will look for templates. The default is templates. This is always relative to the project directory. . is an acceptable value if desired.

#Initializing a New Journal

journal.sh can save you a small amount of typing when creating a journal for the first time. The n or new-journal command is the available tool. journal.sh n my-journal will create a new directory, my-journal, with the default layout or a layout according to your command line arguments. Any supplied command line arguments will also be used to configure this journal.

The journal directory must not exist - this command won't apply a journal layout within an existing directory.

#The Journal Configuration File

journal.config may exist and live at the root directory of any journal. It allows users to configure standard settings. The format is that of a bash script and it will be sourced, if it exists, when journal.sh is invoked.

#Default Configuration

journal_root="entries"
template_root="templates"
selected_suffix=".md"
selected_template="template"
selected_git_upstream="origin"
selected_git_branch="main"

#License

journal.sh is available under the MIT License.

Do not follow this link