Skip to content

Instantly share code, notes, and snippets.

@dllud
Forked from op/bash-history-to-zsh-history.py
Last active April 13, 2021 19:54
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save dllud/8f3b3bb0d911ae8bf530 to your computer and use it in GitHub Desktop.
Save dllud/8f3b3bb0d911ae8bf530 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()
@maddinek
Copy link

first one which worked for me. thanks! :-)

@PLumowina
Copy link

Yes this fork work - goodJob man, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment