Skip to main content

Save command line history and provide a command line completer for python.

Project description

Shield: CC BY-SA 4.0

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

image1

Save command line history and provide a command line completer for python.

Original code is from ActiveState Code » Recipes 2006.06.29 by Sunjoong LEE. ActiveState content is published under CC BY-SA 3.0.

Usage

Insert the lines

import sys
import subprocess

try:
    import berhoel.cmd_line_history
except ImportError:
    # checking if python is running under virtualenv of venv
    is_venv = (
        # This handles PEP 405 compliant virtual environments.
        (sys.prefix != getattr(sys, "base_prefix", sys.prefix))
        or
        # This handles virtual environments created with pypa's virtualenv.
        hasattr(sys, "real_prefix")
    )

    subprocess.check_call(
        [sys.executable, "-m", "pip", "install"]
        + ([] if is_venv else ["--user"])
        + ["pyCmdlineHistory",]
    )

to “~/.pystartup” file, and set an environment variable to point to it:

export PYTHONSTARTUP=${HOME}/.pystartup

in bash.

This will locally install the module for each python you are calling.

Documentation

Documentation can be found here

References

  • Guido van Rossum. Python Tutorial. Python Software Foundation, 2005. 86

  • Jian Ding Chen. Indentable rlcompleter. Python Cookbook Recipe 496812

  • Guido van Rossum. rlcompleter.py. Python Software Foundation, 2005

2006.06.29 Sunjoong LEE sunjoong@gmail.com 2020 - 2023 Berthold Höllmann berhoel@gmail.com

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

pycmdlinehistory-1.1.5.tar.gz (11.4 kB view hashes)

Uploaded Source

Built Distribution

pycmdlinehistory-1.1.5-py3-none-any.whl (13.0 kB view hashes)

Uploaded Python 3

Supported by

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