Created
December 7, 2018 23:39
-
-
Save dhensen/64a5d3a93a499bd75df2f62ef014865c to your computer and use it in GitHub Desktop.
Convert Bash history to zsh history
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 python3 | |
# -*- coding: utf-8 -*- | |
# | |
# Usage: | |
# $ cat ~/.bash_history | ./bash-history-to-zsh-history.py >> ~/.zsh_history | |
import sys | |
import time | |
def main(): | |
# this thing is ineffecient because the whole thing is read into memory just to count lines | |
# only use for small-ish file sizes | |
lines = sys.stdin.readlines() | |
linecount = len(lines) | |
timestamp = time.time() - linecount | |
for line in lines: | |
timestamp += 1 | |
line = line.rstrip('\n') | |
sys.stdout.write(': %s:0;%s\n' % (timestamp, line)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment