Created
September 5, 2017 07:24
-
-
Save nad2000/2ca76b1b55cb796671da5da8a34f6032 to your computer and use it in GitHub Desktop.
migrate bash history to zsh...
This file contains hidden or 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 -*- | |
HOME = os.path.join(home = expanduser("~") | |
import sys, os | |
def main(): | |
bash_history = open(os.path.join(HOME, ".bash_history"), 'r') | |
zsh_history = open(os.path.join(HOME, ".zsh_history"), 'a') | |
timestamp = None | |
for line in bash_history.readlines(): | |
line = line.rstrip('\n') | |
if line.startswith('#') and timestamp is None: | |
t = line[1:] | |
if t.isdigit(): | |
timestamp = t | |
continue | |
elif timestamp: | |
zsh_history.write(': %s:0;%s\n' % (timestamp, line)) | |
timestamp = None | |
close(zsh_history) | |
close(bash_history) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment