[Workflow Script] Obsidian Snippet Manager

Obsidian Snippet Manager is a python script that git pull and move CSS file in your .obsidian/snippet folder.

The goal is to provide a practical way to get semi-auto-update from CSS snippet hosted on GitHub, in waiting of an eventual BRAT update that support that.

Get started

Requirements

  1. Git
  2. Python
  3. pip install Obsidian-Snippet-Manager

Environment

The plugin needs :

  • The absolute path of your vault, as : G:\Drive\Vault
  • A folder that contains all the snippet you want to get the update.
    This folder can be everywhere on your computer (yes, it can be in .obsidian too.). It will contain all folder of the snippet hosted on GitHub you want to use.
    In case of the folder doesn’t exist, the script will create it !

How to use

  1. Adding a new repo : obsnipe clone repository_url
    Additionally, you can exclude a folder from update with adding the --exclude command : obsnipe clone --excluded [repository_url]
  2. Updating everything : obsnipe
  3. Updating only a repository : obsnipe update folder_name
    The folder name is the folder that you want to update the snippet !

The script will :

  • Git pull
  • Git move every .css file in your .obsidian/snippet folder.

Other function

  • obsnipe list : List all GitHub Repository you download.
  • obsnipe exclude [folder_name] : Exclude a folder from update. You can exclude multiple value using : obsnipe exclude [folder1] [folder2]

Note : You can exclude a folder from auto update using the exclude.yml file, placed in your Snipper Manager folder.

Example

Using Obsidian Snippets Collection

  1. Configuration :
    • Vault is in : G:/Drive/vault
    • My Obsidian Manager Folder is in : D:/Documents/Github/Snippets Manager
  2. obsnipe clone https://github.com/Mara-Li/Obsidian-Snippet-collection
  3. Active the snippets :tada:

To update this specific snippet : obsnipe update Obsidian-Snippet-collection

In obsidian

You can create a command in Obsidian using Obsidian Shell.
image



Bonus, you can update your snippet every time obsidian start, like BRAT !

:warning: WARNING : Every edit on a snippet downloaded by this way will break the script. Please, DON’T EDIT these file, and use another snippet ! (Or, use a fork and commit before !)

1 Like

@Jare :eyes: :eyes: :eyes:

1 Like

Hello ! I finally success to release the GUI of Obsidian Snippet Manager to github release :tada:

Things to know :

  • To use the auto-update of Obsidian Shell, you need to install it from pypi using pip install Obsidian_Snippet_Manager --upgrade. Download the executable from release don’t install the CLI command, so you will don’t have the Obsidian Shell auto-update.

  • The executable will not use the same environment file as the package (downloaded from pip), so you need to configure the plugin two times if you want to use the terminal commands (and obsidian shell).

  • Delete the executable folder delete the environment file, so beware when you update your executable.

  • You can use the GUI from terminal using snipetter

GUI_snippeter

Hello :tada:

Now you can choose the snippet you want to download, exclude only snippet from update…

demo2

I also added this to CLI command!

  • obsnipe clone repository_url --excluded [filename] : Add filename to exclude.yml so the script will don’t add it to your obsidian and never add it when you update it.
  • obsnipe clone --select [filename] : Clone the repository and use only the selected CSS. If you don’t exclude the ones you don’t want, it will add them at the update.
  • obsnipe update repository_name --only [filename] : Update only the selected snippet.
  • exclude exclude --add [filename] : Exclude the selected snippet from update. This command edit the exclude.yml.

If you want to manually add snippet to exclude.yml, edit this file with adding the filename with this extension (so filename.css)

A little note about release & executable :

For some reason, windows will warn you about untrustable executable. Moreover, your antivirus might not like it either. The executable is built using GitHub Action : I don’t touch it. You can, also, check every file in the download if you don’t trust me. The only data send to internet is for git clone and push.

The (short) story about certification and untrustable executable : Microsoft want me to pay a lot to sign a little executable. More information about signing on Microsoft Docs

A free signing will always force the end-user to manually install the certificate on their machine

If you don’t trust me : You can build yourself the executable using : pyinstaller Obsidian_Snippeter/GUI.py --name "Obsidian-Snippet-Manager" --windowed --i Obsidian_Snippeter/src/gui_bin/hand.ico --noconfirm --add-data 'Obsidian_Snippeter/src/gui_bin/*;Obsidian_Snippeter/src/gui_bin/' --distpath artifact after cloning. You will see the same error. I have too this error.

(Note that you won’t see it using the terminal commands :blush:)