Is it possible and reasonably easy to make an extension which modifies the JupyterLab File Browser? In particular, I would love to add in an additional “right click” option for folders which executes some code based on the chosen folder.
Basically, add another option to the bottom of the list
which then runs a shell command using the path of the selected folder.
If this isn’t possible, is there another easy “hooks” to have an extension trigger shell code given a selected folder?
Yes, this is possible with code this like (you will want to use a
different selector)
const selectorNotDir = '.jp-DirListing-item[data-isdir="false"]';
app.contextMenu.addItem({
command: "runthiscommand",
selector: selectorNotDir,
rank: 1
});
The needed logic to implement the command itself (and find the
selected folder) can be found in the file browser extension and is
used for our existing commands.
1 Like
Great! Related followup. What is the minimal example extension template to look at for adding this sort of behavior with minimal UI elements, no themes, etc. (I say example because the documentation for extensions is tailored to much more complicated setups).