Giter Club home page Giter Club logo

obsidian-hotkeys-for-templates's Introduction

Hotkeys for templates

Plugin for Obsidian

How to use

This plugin lists all of your template files in its settings pane. You have to enable the template files, which you want a command for. Then you can set a hotkey for the command through the default "Hotkeys" section in the settings. Just search for "Hotkeys for templates".

Important: You have to enable and set a template folder in the core template plugin settings. Search for it in the help vault if you don't know the core plugin.

Supported templates:

  • Templates from the core templates plugin
  • Templates from the Templater plugin

Settings Hotkeys section

Compatibility

Custom plugins are only available for Obsidian v0.9.7+.

Installing

From Obsidian

  1. Open settings -> Third party plugin
  2. Disable Safe mode
  3. Click Browse community plugins
  4. Search for "Hotkeys for templates"
  5. Install it
  6. Activate it under Installed plugins

From GitHub

  1. Download the latest release
  2. Move manifest.json and main.js to <vault>/.obsidian/plugins/obsidian-hotkeys-for-templates
  3. Go to settings and disable safe mode
  4. Enable Hotkeys for templates

If you find this plugin useful and would like to support its development, you can support me on Ko-fi.

Ko-fi

obsidian-hotkeys-for-templates's People

Contributors

luckman212 avatar vinzent03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

obsidian-hotkeys-for-templates's Issues

Default Template doesn't work with nested folders

Hi @Vinzent03!

CC @Moonbase59

Thank you so much for adding support for default templates for specific folders!

I have noticed that it currently doesn't work with nested folders though, which is something I would find super useful.

Expected Behaviour

Default templates work for nested folder structures.

  • 'Deepest match' has priority (if both /a/ and /a/b/ have templates specified, use template for /a/b/

Actual Behaviour

Does not work for nested folders.

My setup is:

image

But the template is only activated for files that are in / directly, not in, for example /Physics/.

This is not just for defining templates in / though. I have a template set for /Physics/ as well in order to try to alleviate this, but /Phyiscs/Quantum/newfile.md will not make use of the /Physics/ template.

Feature Request: Possible to trigger new templated note WITHOUT using a hotkey or command?

Just asking: Since we can enter folder/template pairs already to specify which template should be used for which file when creating a new note, would it be possible to have this when not using a hotkey or command palette command?

For example, I would create a new file using the Obsidian functions (Ctrl+N, right-click in file explorer and select "New Note" or the like) within a folder that is specified in the plugin settings, could it then also automatically intervene and apply the specified template?

This would make it so much more usable (we only have so many keys …), by just always creating a templated new note within specified folders!

Bug when using hotkeys for templates that work on selected words.

Hi I've been trying set up hotkeys for a simple template file like such:

<mark class="blue"><% tp.file.selection() %></mark>

The template works as expected when I use the Templater plugin. However when I use the hotkeys , the selected words doesn't seem to be passed on to the template script like the result below

image

Is this a known bug?

Bug interacting with Templater

OS: Windows 10
Hotkeys for Templates 1.4.2 -- Templater version: >1.8.1
Obsidian version: 0.12.16
Templater ... ## <% tp.date.now("HHmm") %> –

Describe the bug
I have the above Template attached to a hotkey (using the 'Hotkeys for Templates' plugin - Alt+T). It has stopped working in the last 24 hours (>v1.8.1 of Templater).

Expected behaviour
Alt+T calls and renders an H2 with the current time.

Additional context
I initially posted a bug report on the Templater git - they got back to me with the following (apologies for this, as I don’t really understand what they are actually saying here)...

"I believe you will find a this.templaterPlugin.templater.append_template is not a function error in the console.

I think this error comes from the append_template having changed name during a refactor. This should probably be filed as a bug with Hotkeys For Templates plugin, not Templater itself."

Cannot configure the plugin in Preferences

Hey

Firstly thanks for making this plugin. It's super useful to be able to assign to a hotkey the ability to create a new file in a location for a template.

It's been a while since I've had to touch the settings for this so apologies if I am using it wrong. I noticed that the settings for the plugin in the Obsidian preferences was empty.

image

I am using the latest version of the plugin, and I am running Obsidian v1.4.3.

Please let me know if you need any more info, thank you!

Invoke with Tab

This plugin is awesome. Is there a way to invoke it using only the Tab key? I want to replace the default Tab function with $\qquad$.

Creation of a new note via link doesn't trigger the template insertion

Assume that a template _fruitTemplate has been defined for the folder Fruit:

Steps

  1. Create a note anywhere in the vault with a link of [[Fruit/Apple]]
  2. Click on the link in that note to create the new note.

Expected Behaviour: a new note called "Apple" is created in the folder "Fruit", with _fruitTemplate inserted
Actual Behaviour: the new note is created, but _fruitTemplate is NOT inserted

Comments

  • Vault is set to use absolute paths, in case that has an impact
  • this behaviour may be as intended, but personally I'd expect the plugin to insert the template for a folder no matter how that note is created (link, new note hotkey/default folder, file folder right click and new, command palette, etc)

Not compatible with Templater v1.6.0

Hey all,

Updated to Templater v1.6.0 earlier today and as a result the following feature, in this plug, did not work...

image

I have keyboard shortcuts tied to these too and after updating Tempalter … all I got was an Untitled page in the folder specified.

So this was the code I adjusted to fix it...

In .obsidian\plugins\obsidian-hotkeys-for-templates\main.js, I adjusted LINE 2372 from,

case 1: return [4 /*yield*/, this.templaterPlugin.parser.replace_templates_and_append(file)];

to:

case 1: return [4 /*yield*/, this.templaterPlugin.templater.append_template(file)];

Regards,
://mk

After changing/removing "Add new note" entry, hotkey still available

I used "add new text field" to enter Folder=People and Template=Templater: Character, then later changed it to Folder=People/Friends & Family, Template=Templater: Character.

Under Settings → Hotkeys, it now still shows both:

Auswahl_023

Using Obsidian 0.12.3 on Linux, Hotkeys for templates 1.2.1, Templater 1.6.0.

Only after restarting Obsidian, the Hotkeys entries are shown correctly again.

When moving a template from folder, hotkeys for template doesn't update template path

Hi,
When moving a template from folder, hotkeys for template doesn't update template path for already set hotkeys.

To recreate the bug :

  1. Create a template X
  2. enable the template hotkey in "hotkey for template" settings
  3. Create a hotkey in "hotkeys" settings
  4. Move the template X in another folder
  5. Come back in hotkey for template settings. Here you should see that the template X is disabled as it has been moved in the other folder
  6. Check the "hotkeys" settings. The hotkey for the old template X path still exists. The only way to remove it is to move back template x in the previous path, then disable the template hotkey in "hotkey of template" settings (or edit the hotkeys file of obsidian manually). Then move it and enable it again.

Again thanks a lot for this plugin, it saves me time everyday.
Enjoy your day !
Michaël

Edit : Same happen if changing the name of a template.

New file creation along with tp.file.move/tp.file.rename results in extra empty file

I have the following template. It's got a little bit of templater script at the bottom to update a value in the template and move/rename the output file. It doesn't matter if I use tp.file.move or tp.file.rename, in both cases, no matter the output path configured for the new file hotkey, I end up with an extra empty Untitled.md note. This extra note does not get created if using the Templater: Create new note from template command and selecting the same output folder as the hotkey.

---
metatable: true
title: Untitled
campaign: Curse of Strahd
session: 005
session_date: <% tp.date.now("MM.DD.YYYY") %>
tags: RPG/CurseOfStrahd, RPG/SessionNotes/DM
notes_folder: "/RPGs/Curse of Strahd/Meta/Session Notes/"
---
# `= this.title`[[|Last Session]] / [[|Next Session]]**date:** `= this.session_date`
**PC:** [[Anton (Valros)|Anton]], [[Lucky Tenny]], [[Viktor Voronkov]], [[Zoe]]
**NPC Active:**
**NPC Discussed:**
**Location Active:**
**Location Discussed:**
**Monsters:**

## Post session notes

## To do before next session

## Soon

<%*
const frontmatter = this.app.metadataCache.getFileCache(tp.config.template_file)?.frontmatter;
const {update} = this.app.plugins.plugins["metaedit"].api;
// Get current session number, next session number
const oldNumber = frontmatter.session;
const newNumber = `${oldNumber + 1}`.padStart(3, '0');
const oldNumberPadded = `${oldNumber}`.padStart(3, '0');

// Update title of new file
let title = tp.file.title;
if (title.startsWith("Untitled")) {
  title = `S${oldNumberPadded} ${tp.date.now("MM.DD.YYYY")}`;
  await tp.file.rename(`${title}`);
}

// Update session number in template
await update('session', newNumber, tp.config.template_file);
%>

The extra file ends up in the folder specified in the hotkey.

Applies the template twice

When "Trigger on file creation" is active and a hotkey is specified for a new file in a specified folder, upon pressing the hotkeys, the template gets applied twice. I don't want to add hotkey for certain folder but simply enable trigger template on creation whereas I use hotkey for some folders for new note creation.
image

Plugin Options blank on v0.12.12

When I activate the plugin and go to Plugin Options, the page is blank with no fields, switches, or text of any kind. Could this be something with v0.12.12?

Error upon opening: Failed to load plugin obsidian-hotkeys- for-templates

I reviewed issue #21, thinking I had the same issue, but this appears to be something different. I have my template directory defined in the core templates plugin and also the templater plugin. I keep my templates in Setup/templates, which may be a little unusual, so I changed it to just templates for testing purposes but have the same issue.

This has been working for a very long time. I am now running the latest pre-release, so there may have been a config change in the core app. >shrug<

I should also note that I completely removed the plugin and ensured the plugin directory was removed and reinstalled... just in case there was some syncing funny business going on.

Upon loading Obsidian, I get the following error.
Screenshot 2023-10-05 at 05 11 47

If I examine the console, I see.
Screenshot by Dropbox Capture

App Version
Screenshot by Dropbox Capture

Thanks for the great plugin.

(little) Conflict with "Filename Heading Sync"

Hi !

I've just tried your plugin and love it !
I've met a little conflict with the "Filename Heading Sync" plugin which sync the file name with the H1 of the note.

So when I create a new note with the sync of the title and the automatic addition of the template : The following actions are done :

  1. I create the new note
  2. Filesync sync the filename with the title and so add to the top of the note "# title"
    image
  3. Hotkey for template add automatically a template to the note at the beginning of the file so before the "#title"
    image
  4. Filesync sync again the title
    image

Consequence : the title appears both at the beginning and at the end of a note, instead of just being on the top.

Solution : Add a way to consider the H1 title created by "Filename Heading Sync" and add the template below.
Solution 2 : Delay the action of "Filename Heading Sync" , so that the template is first loaded and then the title synced.

Would it be possible to implement one of those solutions ? I can also open an issue on the side of the Filename Heading Sync plugin.

Many thanks for your work !

Michaël

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.