Skip to content

Instantly share code, notes, and snippets.

@zanglang
Created March 23, 2018 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanglang/a7cb97df1f5d6dfe53b3f179a485a97a to your computer and use it in GitHub Desktop.
Save zanglang/a7cb97df1f5d6dfe53b3f179a485a97a to your computer and use it in GitHub Desktop.
Migrate Fish Shell's history file to Zsh
#!/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