mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 09:20:57 +01:00
make history show all sorted
This commit is contained in:
parent
02e1938edb
commit
6f0c635c93
1 changed files with 11 additions and 7 deletions
|
@ -70,6 +70,15 @@ def _gc_bytes_to_rmfiles(hsize, files):
|
||||||
return rmfiles
|
return rmfiles
|
||||||
|
|
||||||
|
|
||||||
|
def _get_history_files(reverse=False):
|
||||||
|
data_dir = builtins.__xonsh_env__.get('XONSH_DATA_DIR')
|
||||||
|
data_dir = expanduser_abs_path(data_dir)
|
||||||
|
files = [os.path.join(data_dir, f) for f in os.listdir(data_dir)
|
||||||
|
if f.startswith('xonsh-') and f.endswith('.json')]
|
||||||
|
files.sort(key=lambda x: os.path.getmtime(x), reverse=reverse)
|
||||||
|
return files
|
||||||
|
|
||||||
|
|
||||||
class HistoryGC(threading.Thread):
|
class HistoryGC(threading.Thread):
|
||||||
"""Shell history garbage collection."""
|
"""Shell history garbage collection."""
|
||||||
|
|
||||||
|
@ -266,18 +275,13 @@ def _all_xonsh_parser(**kwargs):
|
||||||
|
|
||||||
return format: (cmd, start_time, index)
|
return format: (cmd, start_time, index)
|
||||||
"""
|
"""
|
||||||
data_dir = builtins.__xonsh_env__.get('XONSH_DATA_DIR')
|
|
||||||
data_dir = expanduser_abs_path(data_dir)
|
|
||||||
|
|
||||||
files = [os.path.join(data_dir, f) for f in os.listdir(data_dir)
|
|
||||||
if f.startswith('xonsh-') and f.endswith('.json')]
|
|
||||||
ind = 0
|
ind = 0
|
||||||
for f in files:
|
for f in _get_history_files():
|
||||||
try:
|
try:
|
||||||
json_file = LazyJSON(f, reopen=False)
|
json_file = LazyJSON(f, reopen=False)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Invalid json file
|
# Invalid json file
|
||||||
pass
|
continue
|
||||||
commands = json_file.load()['cmds']
|
commands = json_file.load()['cmds']
|
||||||
for c in commands:
|
for c in commands:
|
||||||
yield (c['inp'].rstrip(), c['ts'][0], ind)
|
yield (c['inp'].rstrip(), c['ts'][0], ind)
|
||||||
|
|
Loading…
Add table
Reference in a new issue