diff options
| author | Devendra | 2014-04-26 00:23:30 +0530 | 
|---|---|---|
| committer | Devendra | 2014-04-26 00:23:30 +0530 | 
| commit | 769c3a908890a15c8f5e08cd651e1120194c2e74 (patch) | |
| tree | 9cfa391ce32b76d1c973172f0c90a089d2b3f8f3 /python/examples | |
| parent | 03eedf317ae660893f61bb919b48289b0bf971f3 (diff) | |
| download | pubnub-python-769c3a908890a15c8f5e08cd651e1120194c2e74.tar.bz2 | |
save history to file
Diffstat (limited to 'python/examples')
| -rw-r--r-- | python/examples/console.py | 16 | 
1 files changed, 16 insertions, 0 deletions
| diff --git a/python/examples/console.py b/python/examples/console.py index 225c7eb..8a3ab3b 100644 --- a/python/examples/console.py +++ b/python/examples/console.py @@ -14,6 +14,22 @@ from cmd2 import Cmd, make_option, options, Cmd2TestCase  import optparse  import json +import atexit +import os +import readline +import rlcompleter + +historyPath = os.path.expanduser("~/.pubnub_console_history") + +def save_history(historyPath=historyPath): +    import readline +    readline.write_history_file(historyPath) + +if os.path.exists(historyPath): +    readline.read_history_file(historyPath) + +atexit.register(save_history) +  of=sys.stdout  color = Cmd() | 
