#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# This is how I used it: | |
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.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 | |
continue | |
else: | |
sys.stdout.write(': %s:0;%s\n' % (timestamp or time.time(), line)) | |
timestamp = None | |
if __name__ == '__main__': | |
main() |
Like a charm on Ubuntu 17.10 too!
worked on Ubuntu 14.04, Thanks.
Worked like a charm on Mac
Just an update that this one works really well :)
Ubuntu 18.10
works on ubuntu 19.04 python 2.7.16
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
zsh 5.5.1 (x86_64-ubuntu-linux-gnu)
thanks!!
Works for me on Ubutnu 18.04!
Debian Buster, works good.
Worked like a charm (Ubuntu 18.04). Thanks!
OSX Catalina, works fine! =D
Python 2.7.16
Nice!! Worked beautifully!
Thanks !!!! worked on WSL - python3.8
You're awesome @muendelezaji. Thanks for this. Worked so well.
Works!!
awesome!
Great, thanks :)
Armbian 21.02.3 Focal (Orange Pi) worked! Thanks!
works well on ubuntu 20.04
Works fine on Manjaro! Thanks!
THANK YOU FOR THIS!!!
Working on Debian 11 (stock) python, either run the script as:
cd ~/ && cp .bash_history .bash_history.bak && cat ~/.bash_history | python3 bash-to-zsh-hist.py >> ~/.zsh_history
Or, symlink python3 > python:
sudo ln -s /usr/bin/python3.9 /usr/bin/python
cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
nice, worked like a charm on my new MacBook Pro.
Perfect. Thanks!
thanks, worked on a new M1 MBP
Thanks, worked on Catalina with python 2.7.16
To get it to work with hstr
, I had to use int(time.time())
Thanks for saving my history!!
On WSL had pretty big history and was using HSTR, so after importing the history had 2 problems:
- Error
zsh: corrupt history file /home/user/.zsh_history
- HSTR showing timestamps
So the solution for me was modified script with thanks to @Zackhardtoname and then several additional steps: - Write date to some other file
.zsh_history_tmp
strings .zsh_history_tmp > .zsh_history
fc -R .zsh_history
Worked well for me on Ubuntu 16.04. Thanks.