https://github.com/c6p/logseq-habit-tracker
Habit tracker for Logseq
https://github.com/c6p/logseq-habit-tracker
Last synced: 3 months ago
JSON representation
Habit tracker for Logseq
- Host: GitHub
- URL: https://github.com/c6p/logseq-habit-tracker
- Owner: c6p
- License: mit
- Created: 2021-08-15T19:04:44.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-07T12:10:36.000Z (over 1 year ago)
- Last Synced: 2025-05-11T19:38:45.997Z (11 months ago)
- Language: Vue
- Size: 124 KB
- Stars: 103
- Watchers: 2
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-logseq - logseq-habit-tracker - Track habits from daily journal pages (🔌 Plugins)
README
> If you like this plugin, you can [buy me a ☕ here](https://www.buymeacoffee.com/c.6p)
# Logseq Habit Tracker


Record your habits under `#habit` block in daily journal, then easily track your habits.
Click on gear (⚙️) icon to edit settings.
* **Habit marker** is a keyword to match habits: `#habit`, it was `Habits` before v0.2.0
* **Habit pattern** is the [regex](https://regex101.com/) to parse habits. See [Customization](#customization) for more examples.
Default format is `Habit text - 1,2,3` and you can add notes after a new line.
Default: `^(TODO|DONE)?\s*(?.*?)(?:| - (?:(?\d*?) times|(?.*?)))$`,
capture groups:
* **habit** group is the identifier for the habit and
* **int** is integer count in special format. i.e `5 times`
* only required to specify a count number - else count
* **count** is comma separated list of things (e.g. numbers, time)
* only required to count comma-seperated list - else 1
* **Ignore Pattern** is the regex to ignore habits matching the habitPattern.
Default value is `TODO .*`. So while `DONE` blocks count `TODO` blocks not.
* **Date [format](https://day.js.org/docs/en/display/format)**: `D.M\ndd` where `\n` is new line.
* **Date [width](https://developer.mozilla.org/en-US/docs/Web/CSS/width#syntax)**: `2em`
For `Frequency / Period`, period is one of `d` (day), `w` (week), `m` (month), `y` (year).
* `3/d` means 3 times per day
* `4/2w` means 4 times in 2 weeks
By checking `At Most` you can model bad habits to avoid.
### Customization
Instead of nesting under `#habit` tag you can also use it in every line and change the format to suit your needs.
#### Example 1
```
14:10 pushups #habit
14:11 #habit drink water
```
Habit Pattern: `\d{2}:\d{2} (?.*)`
##### Example 1a
With optional time and notes. Thanks @someinternetguy
```
pushups #habit
pushups #habit did 10 more than usual today, go me!
14:17 pushups #habit
14:17 pushups #habit yay, I remembered to work out today!
```
Habit pattern: `((\d{2}:\d{2})|())(?.*#habit(\s|\b))`
#### Example 2
Ignore habits with unfinished marker. See [#10](https://github.com/c6p/logseq-habit-tracker/issues/10)
```
- #habit
- qwer - 1,2
- qwe
- qwert - X
```
Ignore pattern: `.*- X` will ignore habit `qwert`
#### Example 3
Do not count comma-separated items. See [#29](https://github.com/c6p/logseq-habit-tracker/issues/29)
```
- #habit
- qwerty - 1,2
- qwerty
```
Both will be counted as 1. Habit pattern: `^(TODO|DONE)?\s*(?.*?)(?:| - .*)$`
### Running the Plugin
* `npm && npm build` in terminal to install dependencies.
* `Load unpacked plugin` in Logseq Desktop client.
### Attribution
* Icon by Microsoft (CC BY 4.0):