Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This is how I used it:
# $ cat ~/.bash_history | python >> ~/.zsh_history
import sys
import time
def main():
timestamp = None
for line in sys.stdin.readlines():
line = line.rstrip('\n')
if line.startswith('#') and timestamp is None:
t = line[1:]
if t.isdigit():
timestamp = t
sys.stdout.write(': %s:0;%s\n' % (timestamp or time.time(), line))
timestamp = None
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment