From: b3nj4m1n Date: Wed, 18 May 2022 09:35:59 +0000 (+0200) Subject: Add config for .python_history X-Git-Tag: v0.2.0.0~48 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/xdg-ninja.git/commitdiff_plain/d6e4de0e68920c57779361f6983f884ef2e8d9e6?ds=sidebyside Add config for .python_history --- diff --git a/programs/python.json b/programs/python.json new file mode 100644 index 0000000..c4e02a3 --- /dev/null +++ b/programs/python.json @@ -0,0 +1,10 @@ +{ + "files": [ + { + "path": "$HOME/.python_history", + "movable": true, + "help": "Export the following environment variables:\n\n```bash\nexport PYTHONSTARTUP=\"${XDG_CONFIG_HOME}/python/pythonrc\"\n```\n\nNow create the file _pythonrc_, and put the following code into it:\n\n```python\nimport os\nimport atexit\nimport readline\n\nhistory = os.path.join(os.environ['XDG_CACHE_HOME'], 'python_history')\ntry:\n readline.read_history_file(history)\nexcept OSError:\n pass\n\ndef write_history():\n try:\n readline.write_history_file(history)\n except OSError:\n pass\n\natexit.register(write_history)\n```\n\n_Credit:_ https://unix.stackexchange.com/a/675631/417527\n" + } + ], + "name": "python" +}