aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrahiel <rahielkasim@gmail.com>2014-11-20 19:48:45 +0100
committerrahiel <rahielkasim@gmail.com>2014-11-20 19:48:45 +0100
commitb2330cb52cd18f959f551a8b992b2521e8af9f80 (patch)
tree4592b1077806d6bc0a71d68792850e90428a92bb
parenta8a47b024a5d7721fd3ab267e5acb4acc1c6a016 (diff)
ignore timestamps from zsh history
-rw-r--r--shellstats.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/shellstats.py b/shellstats.py
index 685b499..4bc6fd4 100644
--- a/shellstats.py
+++ b/shellstats.py
@@ -14,13 +14,13 @@ def main(n=10):
commands = {}
for line in history:
cmd = line.split()
- # if not cmd: continue
if cmd[0] in commands:
commands[cmd[0]] += 1
else:
commands[cmd[0]] = 1
total = len(history)
+ # counts :: [(command, num_occurance)]
counts = sorted(commands.items(), key=lambda x: x[1], reverse=True)
print_top(n, counts, total)
pie_top(n, counts)
@@ -72,6 +72,14 @@ def get_history(history_file=None):
history = [l.strip() for l in h.readlines() if l.strip()]
if shell == "fish":
history = [l[7:] for l in history if l.startswith("- cmd:")]
+ elif shell == "zsh":
+ hist = []
+ for l in history:
+ if l.startswith(': '):
+ hist.append(l.split(';', 1)[-1])
+ else:
+ hist.append(l)
+ history = hist
return history