-
-
Notifications
You must be signed in to change notification settings - Fork 220
Description
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 rungit 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:
-
The file being copied to
~/.nb/dfmoco/my_motor_config.rmcfg
-
The following being appended to
dfmoco/index.md
:### Attached Asset Added: `my_motor_config.rmcfg` \`\`\`json {% include "my_motor_config.rmcfg" %} \`\`\`
-
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.