Skip to content

Instantly share code, notes, and snippets.

@emisjerry
Created February 28, 2024 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emisjerry/5fecaae7a72a72b15daf263c8f6e49a4 to your computer and use it in GitHub Desktop.
Save emisjerry/5fecaae7a72a72b15daf263c8f6e49a4 to your computer and use it in GitHub Desktop.
Cmd-open-settings-by-uri.md Open specified setting window by Advanced URI plugin

<%* /**

  • Using Advanced URI Plugin to open specified settings.
  • settingid: Normally the plugin's folder name. We can find the correct id in plugin's manifest.json
  • Hotkey: Alt+S
  • Ref: Obsidian Advanced URI: https://vinzent03.github.io/obsidian-advanced-uri/actions/settings_navigation */ let oSettingsJson = { "Core: Appearance": "appearance", "Core: Community plugins": "community-plugins", "Core: Plugin browser": "plugin-browser", "Core: Theme browser": "theme-browser", "Core: Settings": "app:open-settings", "Core: Hotkeys": "hotkeys", "Core: Editor > Behavior": "editor>Behavior", // ">" indicates settingsection; 行為 "Plugin: BRAT": "obsidian42-brat>Beta Plugin List", "Plugin: QuickAdd": "quickadd", "Plugin: Open-plugin settings": "open-plugin-settings", "Plugin: Commander": "cmdr", "Plugin: Keyshots": "keyshots", "Plugin: Soundscapes": "soundscapes", "Plugin: Code Styler": "code-styler", "Plugin: Templater": "templater-obsidian", "Plugin: Style settings": "obsidian-style-settings", "Plugin: Other settings":"!obsidian42-brat:BRAT-opentPluginSettings", // "!" indicates executes by command ID "File: Cmd-open-settings-by-uri.md":"@010-Templates/Cmd-open-settings-by-uri.md", // "@" indicates opens file (with path) //"Other settings":"!open-plugin-settings:open-other-plugin-settings" };

let aDisplays = Object.keys(oSettingsJson); let aValues = Object.values(oSettingsJson);

let sValue = await tp.system.suggester(aDisplays, aValues, false, "選擇要設定的外掛"); // (displays, values,...) if (!sValue) return; //console.log(sValue); if (sValue.startsWith("!")) { // Command ID sValue = sValue.substring(1); await app.commands.executeCommandById(sValue); } else if (sValue.startsWith("@")) { // Open file sValue = sValue.substring(1); const oFile = await app.vault.getAbstractFileByPath(sValue) await await app.workspace.getLeaf("tab").openFile(oFile); } else if (sValue.contains(">")) { // Handle settingsection let iIndex = sValue.indexOf(">"); let sID = sValue.substring(0, iIndex); let sSection = sValue.substring(iIndex+1); window.open("obsidian://advanced-uri?vault=MOC&settingid=" + sID + "&settingsection=" + sSection); } else { window.open("obsidian://advanced-uri?vault=MOC&settingid=" + sValue); } -%>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment