-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables history cross sessions (storing in a file)
- Loading branch information
1 parent
58ed6a4
commit d134c3e
Showing
6 changed files
with
32 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
*.iml | ||
*.pyc | ||
p-env | ||
tests/env | ||
tests/envs | ||
dist | ||
prudentia.egg-info | ||
build | ||
.history.txt |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
__version__ = '0.8.1' | ||
__author__ = 'Tiziano Perrucci' | ||
|
||
|
||
import readline | ||
import atexit | ||
import os | ||
|
||
if 'libedit' in readline.__doc__: | ||
readline.parse_and_bind("bind ^I rl_complete") | ||
else: | ||
readline.parse_and_bind("tab: complete") | ||
|
||
|
||
historyPath = os.path.join(os.environ['PRUDENTIA_USER_DIR'], '.history.txt') | ||
|
||
|
||
def save_history(p=historyPath): | ||
import readline | ||
readline.write_history_file(p) | ||
|
||
|
||
if os.path.exists(historyPath): | ||
try: | ||
readline.read_history_file(historyPath) | ||
except: | ||
pass | ||
|
||
atexit.register(save_history) | ||
del os, atexit, readline, save_history, historyPath |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import os | ||
|
||
os.environ['PRUDENTIA_USER_DIR'] = '.' |
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