Skip to content

Instantly share code, notes, and snippets.

@GitMurf
GitMurf / obsidian.templater.quick-capture.js
Last active April 22, 2024 15:14
Obsidian Quick Capture using templater. Activate from anywhere in your vault to record quick ideas, notes, time logging, etc. The Quick Capture file does NOT need to be open.
<%*
//v1.4: Adding option for including a header for each DNP day to fold
//'first' will add to top of file. 'last' will add to bottom of file
let firstOrLastLine = 'first';
//Name of the Quick Capture file. Do NOT include extension '.md'
let qcFileName = 'Quick Capture';
//Leave this blank if you want to use the default file path location (set to '/' to use root of vault)
/* RAINBOW INDENT COLORS */
:root {
/* default */
--font-use-default: var(--default-font);
--font-size-use-default: var(--editor-font-size);
--indent-use-default: 1.8ch;
/* ------- */
/* theme */
--font-use-theme: inherit;
@GitMurf
GitMurf / obsidian.live-preview.css.block-ref-inline.css
Last active February 4, 2024 13:31
CSS for inline block references that works for both NEW CM6 Live Preview and also Preview Mode for both CM5 (Legacy) and CM6 (New)
:root {
/* #7159de (similar to Obsidian purple) */
--block-ref-line-color: grey;
--block-ref-line-type: solid;
--block-ref-line-size: 2px;
/* Set to "inherit" for no bg color */
--block-ref-hover-bg-color: #d4d0d026;
}
/*
@GitMurf
GitMurf / obsidian.templater.create-and-copy-block-ref-id.js
Last active January 10, 2024 11:32
Credit to: @shabegom - Add a block ref to the current line by adding a ^uniqueId on the end and copying to the clipboard the embed reference link so you can quickly paste the block ref somewhere else in your vault. Similar to Roam ctrl + click and drag to create block ref.
<%*
//v1.1: Changed to using the new "view.editor" instead of deprecated "view.sourceMode.cmEditor"
let cmEditorAct = this.app.workspace.activeLeaf.view.editor;
let curLine = cmEditorAct.getCursor().line;
cmEditorAct.setSelection({ line: curLine, ch: 0 }, { line: curLine, ch: 9999 });
function createBlockHash() {
let result = '';
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
@GitMurf
GitMurf / obsidian.api.notion-test.js
Created January 11, 2022 00:52
This is a POC test to connecting to the Notion API from Obsidian
<%*
const notionApiKey = 'YOUR_API_KEY_SEE_COMMENTS_FOR_HOW_TO_GET';
const reqParams = {
url: 'https://api.notion.com/v1/databases',
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${notionApiKey}`,
"Notion-Version": `2021-08-16`,
},
@GitMurf
GitMurf / obsidian.templater.move-line.js
Last active October 10, 2023 11:56
Move the active line of the active file to a chosen file.
<%*
//v1.6.2: Fix with update to Templater where wasn't removing the selected text/line "on move"
//'first' will add to top of file. 'last' will add to bottom of file
let firstOrLastLine = 'last';
//Choose a specific line to move to underneath; overrules firstOrLastLine if true
const bChooseLine = false;
//After moving the line, open the file it was moved to
@GitMurf
GitMurf / obsidian.templater.operation.outliner.select-list-items.js
Last active October 1, 2023 18:00
Add a couple Outliner capability features to Obsidian's native list handling: Hotkey to select all text in current bullet, select all children bullets, select entire line of non list item text.
<%*
const editor = app.workspace.activeLeaf.view.editor;
const getCurSelection = editor.getSelection();
const getCur = editor.getCursor("from");
const curLineNo = getCur.line;
const curLineText = editor.getLine(curLineNo);
const matchBullet = curLineText.match(/^[ \t]*[-\*] (.*)/);
let foundContent = "";
if(matchBullet) {
foundContent = matchBullet[1];
<%*
const openInNewPane = false; //If false, will save link to clipboard
const folderName = `refactor`;
const firstVal = await tp.system.prompt("First thought to add to the new note");
//Client name
const files = await app.vault.getMarkdownFiles();
const links = [];
const finalLinkArr = [];
files.forEach(file => {
<%*
// v0.1
/* START OF USER DEFINED SETTINGS */
// template to use
const templateFolder = "templates";
const templateName = "template_anthony.md";
// creating the new file
const newFileFolder = "test/meetings";
const openNewFile = false;
@GitMurf
GitMurf / attr-table-filters.js
Last active June 13, 2023 03:16
Filtering attribute tables
/*
****************************************************************************************
****************************************************************************************
****************************************************************************************
NOW HOSTING CODE VIA MY MAIN GITHUB REPOSITORY FOR ROAM SO THAT USERS CAN LINK DIRECTLY TO THE CODE AND AUTO UPDATE
GO HERE FOR INSTALLATION INSTRUCTIONS: https://github.com/GitMurf/roam-javascript#installation
****************************************************************************************