forked from colonelpanic/dotfiles
dedup history items in merge_zsh_history
This commit is contained in:
parent
f993549d9f
commit
8370da7542
@ -2,9 +2,24 @@ import re
|
||||
|
||||
history_entry_re = re.compile(": ([0-9]*):[0-9]*;.*")
|
||||
|
||||
|
||||
class dedup(set):
|
||||
|
||||
def contains_add(self, elem):
|
||||
if elem in self:
|
||||
return True
|
||||
else:
|
||||
self.add(elem)
|
||||
return False
|
||||
|
||||
|
||||
def merge_history(filenames):
|
||||
entries = dedup()
|
||||
pairs = [entry for filename in filenames for entry in entry_timestamp_pairs(filename)]
|
||||
return "".join([p[0] for p in sorted(pairs, key=lambda pair: pair[1])])
|
||||
return "".join([
|
||||
p[0] for p in sorted(pairs, key=lambda pair: pair[1])
|
||||
if not entries.contains_add(p[0])
|
||||
])
|
||||
|
||||
|
||||
def entry_timestamp_pairs(filename):
|
||||
|
Loading…
Reference in New Issue
Block a user