Skip to main content

jupyterlab_drag_and_drop_path_extension

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO Donate PayPal

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 pathlib expression 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

  1. Open a target alongside the file browser - a terminal, a Python file, or a notebook
  2. 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
  3. 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) or absolute
  • Python path style (pythonPathStyle) - posix inserts a quoted string literal (default), pathlib inserts a Path(...) expression
  • Pathlib constructor (pathlibConstructor) - pathlib.Path (default) or Path; choose Path only in files that already do from 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; newline gives 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. With newline, 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_server extension, 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 - /proc on Linux, lsof on 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.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyterlab-drag-and-drop-path-extension 1.0.5
File Size Uploaded
jupyterlab_drag_and_drop_path_extension-1.0.5.tar.gz 204.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyterlab-drag-and-drop-path-extension 1.0.5
File Interpreter ABI Platform
jupyterlab_drag_and_drop_path_extension-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 237.1 kB

Release files / jupyterlab_drag_and_drop_path_extension-1.0.5.tar.gz

Download URL jupyterlab_drag_and_drop_path_extension-1.0.5.tar.gz
Size 204.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5d06612fb8f27265c1df99b036cc2af7e3c49904b52478e91d093a46c5fef1e8
BLAKE2b-256 checksum
How to use checksums
f75ee3c773754f654bd6ef0543ccaec6e9992949e21eb894c2eb71d48d94af65
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.5-py3-none-any.whl

Download URL jupyterlab_drag_and_drop_path_extension-1.0.5-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbfacff397c7714d7d8e034333ccb1c068659e29dc00356b386f228adf611fc6
BLAKE2b-256 checksum
How to use checksums
eaabff50cf50ce55653d825e0ec29669c678e6bee2ea9107402e465b4c696067
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

1.0.6

2 release files

This release

1.0.5 This release

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

0.8.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page