]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/blob - programs/python.json
move .xonshrc to `XDG_CONFIG_HOME/xonsh/xonshrc` (#86)
[xdg-ninja.git] / programs / python.json
1 {
2 "files": [
3 {
4 "path": "$HOME/.python_history",
5 "movable": true,
6 "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_Note: This won't work if python is invoked with -i flag._\n\n_Credit:_ https://unix.stackexchange.com/a/675631/417527\n"
7 }
8 ],
9 "name": "python"
10 }