jupyterlab_drag_and_drop_path_extension
v1.0.2
Published
Jupyterlab extension to allow file or folder to be dragged-and-dropped to terminal. And to turn into a path. And if the terminal is a python file or not a terminal but python notebook - it would be turned either into path again (default) or to Pathlib exp
Maintainers
Readme
jupyterlab_drag_and_drop_path_extension
Drag a file or folder from the file browser and drop it onto a terminal, Python file, or notebook to insert its path - no copy-pasting, no typing.
Features
- Drop onto a terminal - inserts the path as a shell-escaped argument and brings the terminal tab to the foreground
- Drop onto a Python file or notebook code cell - inserts a quoted string literal, or a
pathlibexpression joined with the/operator (e.g.pathlib.Path('/home/me') / 'data' / 'file.csv') - Drop onto a notebook - the path lands at the active cell's current cursor position
- Absolute or relative paths - configurable; relative is computed against the terminal's working directory or the open document's directory
- Multi-file safety - drags carrying more than one item are ignored
- Master on/off switch - disable the extension without uninstalling
Usage
- Open a target alongside the file browser - a terminal, a Python file, or a notebook
- Drag a single file or folder from the file browser onto the target
- The path is inserted - shell-escaped in terminals, as a quoted string or a
pathlib.Path(...)expression in Python contexts, or as plain text elsewhere
In notebooks the path lands at the active cell's current cursor position. Whether the path is absolute or relative, and how Python output is formatted, is controlled by the settings below.
Settings
Configure under Settings -> Drag and Drop Path:
enabled- master on/off (defaulttrue)pathType-absoluteorrelative(defaultrelative)pythonPathStyle-posixfor a quoted string literal,pathlibfor aPath(...)expression (defaultposix)pathlibConstructor-pathlib.PathorPath, used whenpythonPathStyleispathlib(defaultpathlib.Path)
Requirements
- JupyterLab >= 4.0.0
Install
To install the extension, execute:
pip install jupyterlab_drag_and_drop_path_extensionUninstall
To remove the extension, execute:
pip uninstall jupyterlab_drag_and_drop_path_extensionAcknowledgements
Thanks to Paul Romer for the inspiration and the discussions about reducing user friction when working with hierarchical folder structures in JupyterLab.
