Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save albertstartup/4ab3c0adaf8c61f2230bdaabf78efea0 to your computer and use it in GitHub Desktop.
Save albertstartup/4ab3c0adaf8c61f2230bdaabf78efea0 to your computer and use it in GitHub Desktop.
Import bash history (has no timestamps) to zsh history.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-history-to-zsh-history.py >> ~/.zsh_history
import sys
import time
def main():
timestamp = int(time.time())
for line in sys.stdin.readlines():
line = line.rstrip('\n')
sys.stdout.write(': %s:0;%s\n' % (timestamp, line))
timestamp += 1
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment