Last active
December 20, 2017 00:25
-
-
Save epichub/1cda5e4d2ac50788052f8c2f1448b414 to your computer and use it in GitHub Desktop.
Convert CSH history to ZSH history from https://gist.github.com/op/3802158
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 python | |
# -*- coding: utf-8 -*- | |
# | |
# This is how I used it: | |
# $ cat ~/.history | bash-history-to-zsh-history >> ~/.zsh_history | |
import sys | |
import re | |
def pairwise(iterable): | |
a = iter(iterable) | |
return zip(a, a) | |
def main(): | |
data = [] | |
for line in sys.stdin.readlines(): | |
data.append(line) | |
for (p1,p2) in pairwise(data): | |
timestamp = re.match(".\+(.+)",p1).group(1) | |
sys.stdout.write(': %s:0;%s' % (timestamp, p2)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment