Created
March 23, 2018 06:24
-
-
Save zanglang/a7cb97df1f5d6dfe53b3f179a485a97a to your computer and use it in GitHub Desktop.
Migrate Fish Shell's history file to Zsh
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
#!/usr/bin/env python2 | |
from __future__ import print_function | |
import re | |
CMD_RE = re.compile(r"^- cmd: (.*)") | |
WHEN = re.compile(r"^when: (\d+)") | |
with open("/home/zanglang/.local/share/fish/fish_history") as f: | |
cmd = when = None | |
for line in f: | |
line = line.strip() | |
if CMD_RE.match(line): | |
cmd = CMD_RE.findall(line)[0] | |
elif WHEN.match(line): | |
when = WHEN.findall(line)[0] | |
print(": %s:0;%s" % (when, cmd)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment