Skip to main content

Overview

kmd allows to build command line driven shells with powerful tab-completion capabilities.

The kmd.Kmd class derives from cmd.Cmd and extends it in the following ways:

  1. Instead of Python’s readline module, kmd.Kmd uses the alternative rl readline bindings.

  2. Setup and tear-down of the readline completer have been moved to preloop and postloop respectively. Subclasses must make sure to call their parents’ implementations.

  3. Incomplete command names are automatically expanded if they are unique.

  4. Command aliases can be defined by extending the aliases dictionary. Alias names apply to all do_, complete_, and help_ attributes.

  5. Lines starting with ‘#’ are treated as comments. The new comment method is invoked, receiving the line as argument.

  6. It is now possible to configure the shell_escape_chars. The default is ‘!’.

  7. If a history_file is set, kmd.Kmd loads and saves the history in preloop and postloop.

  8. The new run method encapsulates the full execution cycle of a Kmd.

Package Contents

kmd.Kmd

Implements the mechanics of a command shell, based on cmd.Cmd.

kmd.completions

Implements a set of ready-to-use completions.

kmg.quoting

Defines constants and functions for writing completions.

Documentation

For further details please refer to the API Documentation.

Development

kmd development is hosted on GitHub where it also has an issue tracker.

Installation

Installation requires Python 2.7 or higher.

Note: kmd uses the rl library which contains a C extension. It is a good idea to review its installation instructions and make sure all dependencies are in place.

To install the kmd package, type:

pip install kmd

Changelog

2.4 - 2022-11-17

  • Upgrade to rl 3.1. [stefan]

  • Update filename completion for readline 8.2. [stefan]

  • Hide do_EOF from completion and help. [stefan]

  • Quote newline characters between double quotes. [stefan]

  • Improve documentation and examples. [stefan]

  • Replace deprecated python setup.py test in tox.ini. [stefan]

  • Remove deprecated test_suite from setup.py. [stefan]

  • Remove setuptools from install_requires. [stefan]

  • Add a pyproject.toml file. [stefan]

  • Include tests in sdist but not in wheel. [stefan]

2.3 - 2019-03-20

  • Clear lastcmd when EOF is hit to avoid an infinite loop. See Python issue 13500. [stefan]

  • Drop explicit GPL because the PSF license is GPL-compatible anyway. [stefan]

  • Update filename completion with new hooks. [stefan]

  • Stop hiding the quoting module in completions and make it available as kmd.quoting. [stefan]

  • Stop using rl.completer.reset because it overrides ~/.inputrc. [stefan]

  • Stop using 2to3. [stefan]

  • Require rl >= 3.0. [stefan]

2.2 - 2012-05-10

  • String and filename quoting was not respected when Kmd.run was called with arguments. [stefan]

  • Switch to a happier looking Sphinx theme. [stefan]

  • Require rl >= 2.2. [stefan]

2.1.2 - 2012-04-14

  • Update documentation more. [stefan]

2.1.1 - 2012-03-29

  • Update documentation. [stefan]

2.1 - 2011-11-05

  • Add Kmd.input method as extension point for subclasses. [stefan]

  • Make sure hostname completion survives a missing hosts file. [stefan]

  • Require rl >= 2.0.1. [stefan]

2.0 - 2011-10-06

  • Add Kmd.aliases dictionary to define command aliases. [stefan]

  • Refactor Kmd.do_help for easier customization. [stefan]

  • Make sure error messages go to stderr. [stefan]

  • Switch to pretty Sphinx-based docs. [stefan]

  • Require rl >= 2.0. [stefan]

1.0 - 2011-07-14

  • Initial release.

Release files for kmd 2.4

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

Source distribution (sdist)

Source distribution for kmd 2.4
File Size Uploaded
kmd-2.4.tar.gz 20.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kmd 2.4
File Interpreter ABI Platform
kmd-2.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 37.1 kB

Release files / kmd-2.4.tar.gz

Download URL kmd-2.4.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4dc1a5e4cc9c43a991aa01edc60e3c503374044bd868f2d38226ee4e0d5044f0
BLAKE2b-256 checksum
How to use checksums
d9f4ac7ee990e19511de078508d4f7538d28ddf62a5420b11f15803bce06b765
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.2

Release files / kmd-2.4-py2.py3-none-any.whl

Download URL kmd-2.4-py2.py3-none-any.whl
Size 16.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8a07273e23567a012544816bfdacd0e34f05c02094838791257b66350aa24614
BLAKE2b-256 checksum
How to use checksums
bf5029434023774d5ee4a454442f90b6e55f41bce43738ec1aa26cd8c619b4f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.2

Release history Release notifications | RSS feed

This release

2.4 This release

2 release files

2.3

2 release files

2.2

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1

1 release file

2.0

1 release file

1.0

1 release file

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