Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env zx
// yabai message
const ym = async (arg) => await $`yabai -m ${arg.split(" ")}`;
const hideAllApps = async () => {
await $`osascript -e 'tell application "System Events" to set visible of every process whose visible is true to false'`;
};
const laptop = 1;
@selfire1
selfire1 / Pre-Publish Template.js
Last active October 7, 2023 06:15
To be run in the Obsidian Templater Plugin to update query files and permalinks. To be saved as a `.md` file.
<%*
const dv = app.plugins.plugins["dataview"].api;
const openPublishPanel = app.commands.commands["publish:view-changes"].callback;
// ----------------------
// Update query files
// ----------------------
const updateQueryFiles = async () => {
const fileAndQuery = new Map([
[
"Books Read (Auto-Updating)",

2022

Daily Journaling

const dayInMonth = moment().format("D");
const currentMonth = moment().format("M");
var i = 1;
while (currentMonth > i) {
    var entries = entriesSum(i);
    var max = daysInMonth(i);
    var perc = entries + "/" + max;
@selfire1
selfire1 / resize.scpt
Last active March 20, 2022 10:56
An Applescript to resize windows from the command line
on run argv
-- Variables
set _cmd to (item 1 of argv)
tell application "Finder" to set _bounds to bounds of window of desktop
set _xPos to (item 1 of _bounds)
set _yPos to (item 2 of _bounds)
set _ySize to (item 3 of _bounds)
set _xSize to (item 4 of _bounds)
-- get bounds
-- do split: app1, app2, set split
@selfire1
selfire1 / ✍ Copy to Weekly.md
Created February 27, 2022 13:26
A script for Templater to copy the line to a weekly note. Change the variables to your setup

<%* // Select active line // Source: https://gist.github.com/GitMurf/c52dfef13162d88375975e4eefedf3a7 const editor = app.workspace.activeLeaf.view.editor; const curLineNum = editor.getCursor().line; editor.setSelection({ line: curLineNum, ch: 0 }, { line: curLineNum, ch: editor.getLine(curLineNum).length }); let copiedStr = editor.getSelection(); copiedStr = copiedStr.trim();

// Replace formatting

@selfire1
selfire1 / Append to daily.md
Created February 20, 2022 07:01
Appending to Daily Notes in Obsidian

<%* // Append to Daily var dailyDate = "DATE"; //date of the daily note to append to/create (eg."2022-05-20" or 'tp.file.now("YYYY-MM-DD")' const append = * TEXT; //text to append

const folder = app.vault.getAbstractFileByPath("20 Journals"); if (!tp.file.exists(dailyDate)) { await tp.file.create_new(append,dailyDate, false, folder) } else { const originalContent = await app.vault.read(tp.file.find_tfile(dailyDate));

@selfire1
selfire1 / add-book-template.md
Last active July 11, 2022 20:58
A template for Obsidian.md to fetch book data from the Google Book API.

// Author: Joschua // Original gist: https://gist.github.com/selfire1/bd1ebf8fd5af629f45a43cef99623236

// Set the amount of search results to fetch maxResults = 3 // Opens a dialogue for book to search for bookQuery = await tp.system.prompt("Enter book to search for 📚🔎");

// Calls the Google Book API to fetch book data

@selfire1
selfire1 / obsidian-monthnotes.sh
Last active December 30, 2021 18:03
A script that creates twelve monthly overview notes in Markdown for use in Obsidian
#!/bin/bash
# Author: Joschua
# Gist script link: https://gist.github.com/selfire1/f9ddddedc19a59eb6b3103ab51dec11d
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@selfire1
selfire1 / release.yml
Created November 3, 2021 21:05
Github Action to automate Obsidian releases. Source: [Release your plugin with GitHub Actions | Obsidian Plugin Developer Docs](https://marcus.se.net/obsidian-plugin-docs/publishing/release-your-plugin-with-github-actions)
name: Release Obsidian plugin
on:
push:
tags:
- "*"
env:
PLUGIN_NAME: FINDME # Change this to match the id of your plugin.
@selfire1
selfire1 / Copy to clipboard.md
Last active December 20, 2022 14:36
Template for the Templater Obsidian plugin to copy current Obsidian note as markdown link

<%* const title = tp.file.title; const uri = 'obsidian://open?vault=Vault&file=' + encodeURI(title); const fullstring = '[' + title + ']' + '(' + uri + ')'; navigator.clipboard.writeText(fullstring); %>