Skip to content

Instantly share code, notes, and snippets.

@dmych
dmych / AutocompleteThemes.md
Created May 27, 2025 17:08
Temlibro ver. 1

<%* // Автодополнение §-ссылок и тем

const activeEditor = app.workspace.activeEditor; if (!activeEditor) { new Notice("Нет активного редактора"); return; }

const editor = activeEditor.editor;

@dmych
dmych / DailyNote.js
Created December 28, 2023 14:39
Шаблон Templater для ежедневной заметки: при создании заметки в нее переносятся все невыполненные задачи из предыдущего дня и копируются задачи на этот день из ежемесячной заметки
## <% tp.user.fmtDates(tp, "ddd DD MMM", true) %>
<%*
// Get tasks from monthly log
const monthlyNote = tp.file.find_tfile(tp.date.now("YYYY-MM", 0, tp.file.title, "YYYY-MM-DD")) // get the TFile of yesterday's note
console.log('monthlyNote='+monthlyNote)
let monthlyNoteData = await app.vault.read(monthlyNote)
let monthlyNoteContent = monthlyNoteData.split("\n")
console.log('content='+monthlyNoteContent)
const header = "## " + tp.user.fmtDates(tp, "ddd DD", true) // replace with whatever the header is
@dmych
dmych / MigrateTomorrow.js
Created December 28, 2023 14:20
Скрипт для переноса (миграции) задачи на следующий день. Работает с помоью плагина Templater в Obsidian
<%*
// get the current task
let re = /(^\s*|^\t*)(-\s\[ \]\s|-\s\[.\]\s|\*\s|-\s|\d*\.\s|\*\s|\b|^)([^\n\r]*)/gim;
let editor = app.workspace.activeLeaf.view.editor;
let cur = editor.getCursor("from");
let text = editor.getLine(cur.line);
// find next daily note, create if not exists
let fname = tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD")
console.log('fname='+fname)
let mname = tp.date.now("YYYY-MM", 1, tp.file.title, "YYYY-MM-DD")
@dmych
dmych / fmtDates.js
Created December 28, 2023 13:16
Получение даты в формате ДН ДД МЕС для использования в плагине Templater для Obsidian
// Форматирование дат по-русски
// tp - ссылка на объект tp, fmt - формат, source == true - взять дату из заголовка файла, false - текущая дата
function fmtDates(tp, fmt, source)
{
const days = ["ВС", "ПН", "ВТ", "СР", "ЧТ", "ПТ", "СБ"]
const mon = ["ЯНВ", "ФЕВ", "МАР", "АПР", "МАЯ", "ИЮН", "ИЮЛ", "АВГ", "СЕН", "ОКТ", "НОЯ", "ДЕК"]
const months = ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "
Декабрь"]
let dateS
if (typeof source === "string") // использовать как дату
@dmych
dmych / NextParagraph.md
Created January 12, 2023 18:59
Go to the next/previous paragraph (e.g. empty line) using Templater scripts. Put all files to your Templater scripts folder, add both .md files to the Template Hotkeys and assign hot keys.

<%* tp.user.para(tp, false) %>

@dmych
dmych / OpenParent.js
Last active January 13, 2023 19:21
This is a Obsidian Templater template which opens the parent note when using Folder Note pluging. Save it as .md file, put to your Templater scripts folder and assign hot key (I prefer Cmd/Ctrl+U)
<%*
let parName = tp.file.folder(true) + '.md';
if (await tp.file.exists(parName)) {
app.workspace.openLinkText('', parName);
}
%>
@dmych
dmych / AltCheckbox.js
Last active November 5, 2023 13:14
A script for Obsidian Templater that allows you to select a checkbox value from a menu. It is recommended to assign a template to a hotkey or a button in the mobile toolbar. Save the template as .md file to your Templater scripts folder.
<%*
let lst = ['[ ] to-do',
'[/] incomplete',
'[x] done',
'[-] canceled',
'[>] forwarded',
'[<] scheduling',
'[?] question',
'[!] important',
'[*] star',