Skip to content

Instantly share code, notes, and snippets.

@mseri
Forked from op/bash-history-to-zsh-history.py
Created December 10, 2013 17:28
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 mseri/7894532 to your computer and use it in GitHub Desktop.
Save mseri/7894532 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | bash-history-to-zsh-history >> ~/.zsh_history
import sys
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
continue
elif timestamp:
sys.stdout.write(': %s:0;%s\n' % (timestamp, line))
timestamp = None
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment