Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FallibleInc/pysession
Automatically saves python shell code to a local file or secret Gist
https://github.com/FallibleInc/pysession
gist ipython python terminal
Last synced: 2 months ago
JSON representation
Automatically saves python shell code to a local file or secret Gist
- Host: GitHub
- URL: https://github.com/FallibleInc/pysession
- Owner: FallibleInc
- License: mit
- Created: 2016-09-13T05:57:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-16T11:14:48.000Z (over 8 years ago)
- Last Synced: 2024-10-13T11:22:12.055Z (3 months ago)
- Topics: gist, ipython, python, terminal
- Language: Python
- Homepage:
- Size: 1.03 MB
- Stars: 86
- Watchers: 6
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - pysession - Automatically saves python shell code to a local file or secret Gist (Python)
README
### Pysession
Automatically save python interpreter code to a file or secret Gist. You can turn this off for any session. Helpful when you want to share a piece of code you just hacked on the shell or wanted to save it in a file for use later.
Tested with IPython, Python2 & Python3 default shells.
![Pysession demo](./pysession_demo.gif)
#### Installation steps
``` bash
pip install pysession
echo 'export PYTHONSTARTUP=$HOME/.pysession/pysession.py' >> ~/.bashrc
```If you are using zsh replace `.bashrc` in the above line with `.zshrc` and similarly for any other shell. On macOS, you should append this to `~/.bash_profile`
#### How to use
By default, Pysession will record each shell run and save to a Gist. However it can be instructed to turn off recording or save to a file locally instead of GitHub.
##### To turn off saving for a session
``` python
>>> PySession.off()
```Alternatively, to persist your choice of not saving sessions for some extended period of time, set an environment variable PYSESSION_SAVE_OFF to True.
`export PYSESSION_SAVE_OFF=True`##### To turn back on saving for a session
``` python
>>> PySession.on()
```##### To save to a local file instead of Gist
``` python
>>> PySession.local()
```To always save your sessions to local file, set an environment variable PYSESSION_SAVE_LOCALLY to True.
`export PYSESSION_SAVE_LOCALLY=True`The file is saved with a name `session.py` You can change this by setting the environment variable PYSESSION_FILENAME to your desired filename.
`export PYSESSION_FILENAME=some_file_name.py`