Last active
June 22, 2022 21:47
-
-
Save nfitzen/e528ccdc9ff3e58f8085ba3b6fd5f964 to your computer and use it in GitHub Desktop.
Disables saving Python interpreter history to a file. Put in your pythonrc and set your PYTHONSTARTUP env variable to point to it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-License-Identifier: CC0-1.0 | |
# SPDX-FileCopyrightText: 2022 nfitzen <https://github.com/nfitzen> | |
# god, this is such a hack | |
# why, python | |
# likely works in CPython 3.7 and up... for now | |
# fix bpo-20886 pls | |
def __PYTHONSTARTUP_historyremove(): | |
import sys, readline | |
register_readline = sys.__interactivehook__ | |
def register_readline_without_history(): | |
hist_len = readline.get_current_history_length | |
readline.get_current_history_length = lambda: -1 | |
register_readline() | |
readline.get_current_history_length = hist_len | |
sys.__interactivehook__ = register_readline_without_history | |
if __name__ == "__main__": | |
__PYTHONSTARTUP_historyremove() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment