Skip to main content

CLI tool to save well-structured notes in Obsidian format

Project description

Obsidian Note CLI

obsidian_note_cli is a command-line tool for creating well-structured notes in Obsidian, complete with front matter metadata like creation date, tags, and status. This tool is designed for users who frequently take notes and want to streamline their note-taking workflow using Obsidian and the command line.

It goes well along with Daniel Miessler's Fabric, as it processes content passed through the stdin as default.

Features

  • Create notes with customizable front matter fields: created_at, tags, status, source, and more.
  • Specify note content via a file or piped input (Linux-style stdout | stdin).
  • Set default values for created_at at today's date.
  • Configuration via environment variables for vault and path, with sensible defaults

Installation

Prerequisites

  • Python 3.8 or higher
  • Poetry for managing dependencies and packaging (optional but recommended)
  • pipx for globally installing CLI tools

Step-by-Step Installation

  1. Clone the Repository

    git clone https://github.com/guglielmo/obsidian_note_cli.git
    cd obsidian_note_cli
    
  2. Build the Package with Poetry

    poetry build
    

Step 3: Install with pipx

Ensure that pipx is installed on your system. Then, use pipx to install the latest version of the CLI tool globally:

pipx install dist/obsidian_note_cli-<VERSION>-py3-none-any.whl

Replace with the latest version of your package (e.g., 0.1.0).

To check the current version, refer to the version specified in the pyproject.toml file or check the release information in your repository if published.

This makes obsidian-note available as a command globally, isolated from other Python environments.

Alternatively, if you are frequently updating and testing new versions, you can specify a specific version or install directly from your local directory after building:

pipx install dist/obsidian_note_cli-$(poetry version -s)-py3-none-any.whl

This command dynamically uses the current version from pyproject.toml by extracting it with poetry version -s.

Usage

Basic Usage

To create a note, specify at least the title, vault, and tags:

obsidian-note --title "My First Note" --vault "MyVault" --path "Notes" --tags "tag1,tag2"

This command saves a note in the specified vault and path with the provided title and tags.

Using Interactive Mode

To enter parameters interactively, use the --interactively flag:

obsidian-note --interactively

Example with Piped Content

You can pipe content into obsidian-note:

echo "This is the note content" | obsidian-note --title "My Piped Note" --vault "MyVault" --path "Notes" --tags "piped,content"

Options

  • --title: Title of the note.
  • --vault: Obsidian vault name (default can be set via environment variable VAULT).
  • --path: Path within the vault to save the note (default can be set via environment variable PATH).
  • --tags: Comma-separated list of tags.
  • --status: Optional status for the note.
  • --created_at: Date in YYYY-MM-DD format (defaults to today).
  • --interactively: Flag to enter parameters interactively.
  • content: The content of the note, provided via a file or stdin.

Configuration via Environment Variables

You can set default values for vault and path using environment variables:

export OBSIDIAN_VAULT="MyVault"
export OBSIDIAN_PATH="Notes"

This configuration allows you to avoid specifying --vault and --path for each note.

Examples

  1. Create a Basic Note

    obsidian-note --title "Daily Log" --vault "WorkVault" --path "Logs" --tags "daily,log" --status "in-progress"
    
  2. Create a Note with Interactive Mode

    obsidian-note --interactively
    
  3. Pipe Content into a Note

    echo "This is piped content" | obsidian-note --title "Piped Note" --vault "MyVault" --path "Notes" --tags "example,pipe"
    
  4. Use with fabric

    fabric -u https://zettelkasten.de/introduction/ | summarize | \
    obsidian-note --path="09.ReadingList" --source=https://zettelkasten.de/introduction/
    

    This is a bit awkward, as for the duplication of the URL, an idea would be to define a bash function:

    function process_note_summarize() {
     local url="$1"
     fabric -u "$url" | summarize | \
     obsidian-note --source="$url" "$@"
    }
    

    so that the whole process of reducing the content of the URL to markdown, summarizing it through the AI and sending it to Obsidian, at a specific folder of the default vault, could be expressed as:

    process_note_summarize "https://zettelkasten.de/introduction/" \
       --path 09.ReadingList --tags self_improvement formation 
    

Development

If you want to modify the tool, follow these steps to set up a development environment:

  1. Clone the repository and navigate into it:

    git clone https://github.com/yourusername/obsidian_note_cli.git
    cd obsidian_note_cli
    
  2. Install dependencies using poetry:

    poetry install
    
  3. Run the tool locally with poetry:

    poetry run obsidian-note --title "Test Note" --vault "TestVault" --path "TestPath" --tags "test"
    

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please feel free to open issues or submit pull requests.

Contact

For questions or suggestions, please contact your.email@example.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obsidian_note_cli-0.1.4.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

obsidian_note_cli-0.1.4-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file obsidian_note_cli-0.1.4.tar.gz.

File metadata

  • Download URL: obsidian_note_cli-0.1.4.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.2 Linux/6.9.2-060902-generic

File hashes

Hashes for obsidian_note_cli-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d7a0a2921b889c398026caf39e9ed05a03002e6fdcd12b56069bc6eb2f74f7d5
MD5 37ca7d39ac360a114689fb64da57d9f2
BLAKE2b-256 ebb8d2a8fbf49abb8af8278c2d573144f01668cc5a8f3ef326cb50c99748a70c

See more details on using hashes here.

File details

Details for the file obsidian_note_cli-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: obsidian_note_cli-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.2 Linux/6.9.2-060902-generic

File hashes

Hashes for obsidian_note_cli-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 95052e270a84d7f92179e774e2471d203d4e0aa6e7d151059aa7655fe2e7d12e
MD5 005b3773712f1668eb541dbcade49c98
BLAKE2b-256 501c941532c75782064ea0c9fd82342e400eae75ea276415efaebb1f4780052a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page