Save command line history and provide a command line completer for python.
Project description
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
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
Built Distribution
File details
Details for the file pycmdlinehistory-1.1.6.tar.gz
.
File metadata
- Download URL: pycmdlinehistory-1.1.6.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.10.2-1-default
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b24950a8875395be5deef7d5196f0541dbfef549ad3288c45bc5d9673b6959a5 |
|
MD5 | 9c00ae2a630c120ef8df0e951ee9e7d5 |
|
BLAKE2b-256 | d69433ba1a9132eac242bf26ad875eaf0806c66a9be10cb5279ec30c0c8908f7 |
File details
Details for the file pycmdlinehistory-1.1.6-py3-none-any.whl
.
File metadata
- Download URL: pycmdlinehistory-1.1.6-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.10.2-1-default
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a20feddec3a6732b7ba35ddded33a5c288a48f665ea8885db3d550b1621d0adf |
|
MD5 | 51bd0a4182d4dfcfd203c160d973c202 |
|
BLAKE2b-256 | ec75bc32fb2ceacd4a7f1c8b4fa2a68568c2b0c556a9185e63c5f13821996693 |