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, or a single-quoted one where quoting is turned on, and brings the terminal tab to the foreground
- Drop several files onto a terminal - every dragged path is inserted at once, in the order you selected them, separated either by a space or by a newline
- 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 any other file - markdown, text, JSON and the rest receive the bare path, with no quoting
- Absolute or relative paths - configurable; relative is computed against the terminal's working directory or the open document's directory
- Drag from the breadcrumbs too - the folder trail above the file listing is a drag source, so the directory the browser is showing can be dropped on a target without first finding its row
- 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 file or folder from the file browser onto the target - or several of them, onto a terminal
- A crumb in the folder trail above the listing can be dragged in the same way, which inserts that directory's path; the home crumb stands for the server root
- 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 in the cell you drop it on, at that cell's cursor position; a drop away from any cell goes to the active cell. A breadcrumb drag inserts a path and nothing else - it is declined by the file listing and by the other crumbs, so it can never move the directory it names, and a crumb that is clicked rather than dragged still navigates. A drag carrying several items is taken by a terminal only - an editor or a notebook refuses it and the cursor shows no-drop. Whether the path is absolute or relative, how Python output is formatted, and how several terminal paths are separated, is controlled by the settings below.
Settings
Open Settings → Settings Editor → Drag and Drop Path. Each entry below leads with the label the editor shows, with the JSON key in brackets for anyone editing the raw settings:
- Enable drag-and-drop path insertion (
enabled) - master on/off, default on - Path type (
pathType) -relative(default) orabsolute - Python path style (
pythonPathStyle) -posixinserts a quoted string literal (default),pathlibinserts aPath(...)expression - Pathlib constructor (
pathlibConstructor) -pathlib.Path(default) orPath; choosePathonly in files that already dofrom pathlib import Path, because the extension inserts no import - Terminal separator for several paths (
terminalSeparator) -space(default) keeps the paths on one line as arguments;newlinegives each path a line of its own, ending every line but the last with a backslash so the shell reads it as a continuation. Nothing runs until you press Enter under either value. Withnewline, type the command before you drop: in bash, once the paths are in, only the last line can still be edited, and a command typed at the front of it runs the first dropped path instead; zsh keeps the whole buffer editable - Quote paths in the terminal (
terminalQuotePaths) - off by default, so paths are backslash-escaped; on, each path is wrapped in single quotes instead. Both forms reach the shell as one argument per path, and quoting is the easier of the two to edit by hand afterwards
Requirements
- JupyterLab >= 4.0.0
- The wheel also installs and auto-enables a
jupyter_serverextension, which supplies the server root and each terminal's working directory - Relative paths in a terminal need that server extension and a readable process table -
/procon Linux,lsofon macOS. Where it is unavailable the extension inserts nothing rather than a wrong path; absolute paths and all editor and notebook drops are unaffected
Install
To install the extension, execute:
pip install jupyterlab_drag_and_drop_path_extension
Uninstall
To remove the extension, execute:
pip uninstall jupyterlab_drag_and_drop_path_extension
Acknowledgements
Thanks to Paul Romer for the inspiration and the discussions about reducing user friction when working with hierarchical folder structures in JupyterLab.
Metadata
Release files for jupyterlab-drag-and-drop-path-extension 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jupyterlab_drag_and_drop_path_extension-1.0.6.tar.gz | 204.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jupyterlab_drag_and_drop_path_extension-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 237.4 kB
Release files / jupyterlab_drag_and_drop_path_extension-1.0.6.tar.gz
| Download URL | jupyterlab_drag_and_drop_path_extension-1.0.6.tar.gz |
|---|---|
| Size | 204.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b05ad8c3cd47885b2367f1db0a420c420b66ca7b25a21ebd2eb763137cb4fa8e
|
|
BLAKE2b-256 checksum How to use checksums |
9533754232f37114d9bac709f7bcbf7172c683f09fac3fa1c730cc9cd16115a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / jupyterlab_drag_and_drop_path_extension-1.0.6-py3-none-any.whl
| Download URL | jupyterlab_drag_and_drop_path_extension-1.0.6-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba461996b384ea71578d1931783211847b91fe9096f875613addf6daefc31c74
|
|
BLAKE2b-256 checksum How to use checksums |
14cfaa82445a8e140710dbbe39b9611eb25df73430f6666b68c7df55bca0fcde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|