Skip to main content

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 expression (depending on the config in the settings)

Project description

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 and brings the terminal tab to the foreground
  • 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 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

  1. Open a target alongside the file browser - a terminal, a Python file, or a notebook
  2. Drag a single file or folder from the file browser onto the target
  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 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 (default true)
  • pathType - absolute or relative (default relative)
  • pythonPathStyle - posix for a quoted string literal, pathlib for a Path(...) expression (default posix)
  • pathlibConstructor - pathlib.Path or Path, used when pythonPathStyle is pathlib (default pathlib.Path)

Requirements

  • JupyterLab >= 4.0.0

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_drag_and_drop_path_extension-1.0.2.tar.gz (258.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file jupyterlab_drag_and_drop_path_extension-1.0.2.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_drag_and_drop_path_extension-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8e12f2ca7b7d13a7ebe94dc554294f53f80f879b3189f54f1703e33d0209c83c
MD5 3f67578408ac8f01dd485a8dea65bd9f
BLAKE2b-256 b9bc2b9531ea27a3ac428cff2e264c839fe696b28d27ae9784085019b066de2f

See more details on using hashes here.

File details

Details for the file jupyterlab_drag_and_drop_path_extension-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_drag_and_drop_path_extension-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 18a7b3823e0e264ec381f9f963f4a06bbbe8c0987ec54f4fc1b42b7e5d5d2e26
MD5 b8dce99ba6427a263c0e777a40c004e8
BLAKE2b-256 18c0813b34d94302752a9e7e275cc0cc9d126e1a8872e18b9722d7b31bba36b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page