Skip to content

Feature Proposal: nb asset add #370

@flipphillips

Description

@flipphillips

Feature Request: nb asset add Command

Goal

Introduce a new subcommand to simplify the process of adding non-Markdown files (e.g., JSON, images, PDFs) into a notebook directory managed by nb, with optional inline reference in the main note file.


Proposed Command

nb asset add ~/Downloads/my_motor_config.rmcfg --notebook dfmoco

This command would:

  • Copy (or optionally symlink) the file into the selected notebook folder
  • Optionally insert a reference or fenced code block in index.md (or another target file)
  • Optionally stage the file for Git

Optional Flags

  • --link: Use a symlink instead of copying the file
  • --inline: Insert contents into the notebook using a fenced code block (e.g., JSON or plaintext)
  • --no-edit: Add the file but don’t update the note
  • --git: Automatically run git add on the file

Example Behavior

If I run:

nb asset add ~/Downloads/my_motor_config.rmcfg --notebook dfmoco --inline --git

This would result in:

  1. The file being copied to ~/.nb/dfmoco/my_motor_config.rmcfg

  2. The following being appended to dfmoco/index.md:

    ### Attached Asset
    
    Added: `my_motor_config.rmcfg`
    
    \`\`\`json
    {% include "my_motor_config.rmcfg" %}
    \`\`\`
  3. The file staged for commit with Git


Motivation

Many users (like myself) use nb to manage project-related documentation and data files. Currently, there’s no native support for easily adding and referencing external files like configuration files, data assets, or media. This feature would streamline that process and keep notebooks clean and consistent.


Other Thoughts

I can imagine this may have been proposed before in some form and maybe quashed for the sake of 'text file simplicity / supremecy' --- in which case I totally understand the design philosophy decision, but, like a good annoyance, would like to suggest this as a potential direction of future development.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions