Skip to main content

symlink-editor

A TUI (text based user interface) written in Python with prompt-toolkit to edit symlinks.

Features:

  • The color of the frame indicates whether the target exists or not.
  • The color of the path indicates which part of the path is broken.
  • The cursor is placed at the beginning of the broken part of the path.
  • Tab completion and completion menu showing all existing files and directories at the cursor position.
  • Change the target into a relative path with Ctrl+R. Press Ctrl+R again to make the target relative to the canonical path.
  • Change the target into an absolute link with Ctrl+A. Press Ctrl+A a second time to canonicalize the path. By pressing Ctrl+A a third time it is possible to switch back to the symlink-version of the the working directory, but symlinks in the original target remain resolved.

Installation

This program is distributed via PyPI so you can easily install it with pipx:

$ pipx install symlink-editor

Usage in a terminal

$ symlink-editor path/to/symlink

Integration in other terminal applications

If you want to integrate this program into yazi, ranger or other terminal applications I recommend to use the --window flag. With that all feedback such as error messages or updated link will be displayed in a prompt toolkit window instead of printed to stdout so that they won't be overwritten by the other application before you can read them. You can dismiss the window by pressing Enter, Ctrl+C or Q.

Note that the --window flag can only take effect after all command line arguments have been parsed. That means that it does not apply to error messages from incorrect command line arguments and the output of --help and --version.

For yazi you can add the following to ~/.config/yazi/keymap.toml:

[[manager.prepend_keymap]]
on = [ "e", "l" ]
run = 'shell --block "symlink-editor --window \"$0\""'
desc = "edit symlink"

License

This is free software. It is licensed under the BSD Zero Clause License. You can freely use, modify, and distribute it. See LICENSE.

Running the tests

I am using mypy for static type checking and pytest for dynamic testing. tox creates a virtual environment and installs all dependencies for you. You can install tox with pipx (pipx install tox).

$ tox

In order to make tox work without an internet connection install devpi:

$ pipx install devpi-server
$ devpi-init
$ devpi-gen-config
$ su
# cp gen-config/devpi.service /etc/systemd/system/
# systemctl start devpi.service
# systemctl enable devpi.service

and add the following line to your bashrc:

export PIP_INDEX_URL=http://localhost:3141/root/pypi/+simple/

Metadata

Release files for symlink-editor 1.3.0

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

Source distribution (sdist)

Source distribution for symlink-editor 1.3.0
File Size Uploaded
symlink_editor-1.3.0.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for symlink-editor 1.3.0
File Interpreter ABI Platform
symlink_editor-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

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