Skip to content

Commit

Permalink
Keep signac shell command history on a per-project basis. (#194)
Browse files Browse the repository at this point in the history
* Keep signac shell command history on a per-project basis.

Resolves issue #134.

* Update changelog.

* Fix Py27 incompatibility.

* Readline module not fully implemented for PyPy.
  • Loading branch information
csadorf committed May 21, 2019
1 parent cbe589d commit bbf2b74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Highlights
- Support for compressed Collection files.


next
----

- Keep signac shell command history on a per-project basis.

[1.1.0] -- 2019-05-19
---------------------

Expand Down
12 changes: 12 additions & 0 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import logging
import getpass
import difflib
import atexit
import code
import importlib
import platform
from rlcompleter import Completer
import re
import errno
Expand Down Expand Up @@ -1000,6 +1002,16 @@ def jobs():
interpreter.runsource(args.command, filename="<input>", symbol="exec")
else: # interactive
if READLINE:
if 'PyPy' not in platform.python_implementation():
fn_hist = project.fn('.signac_shell_history')
try:
readline.read_history_file(fn_hist)
readline.set_history_length(1000)
except (IOError, OSError) as error:
if error.errno != errno.ENOENT:
raise
atexit.register(readline.write_history_file, fn_hist)

readline.set_completer(Completer(local_ns).complete)
readline.parse_and_bind('tab: complete')
code.interact(
Expand Down

0 comments on commit bbf2b74

Please sign in to comment.