Skip to content

Instantly share code, notes, and snippets.

@01farshad
Forked from muendelezaji/bash-to-zsh-hist.py
Created July 2, 2019 03:43

Revisions

  1. @muendelezaji muendelezaji renamed this gist Oct 5, 2016. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions bash-history-to-zsh-history.py → bash-to-zsh-hist.py
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,10 @@
    # -*- coding: utf-8 -*-
    #
    # This is how I used it:
    # $ cat ~/.bash_history | bash-history-to-zsh-history >> ~/.zsh_history
    # $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history

    import sys
    import time


    def main():
    @@ -16,10 +17,10 @@ def main():
    if t.isdigit():
    timestamp = t
    continue
    elif timestamp:
    sys.stdout.write(': %s:0;%s\n' % (timestamp, line))
    else:
    sys.stdout.write(': %s:0;%s\n' % (timestamp or time.time(), line))
    timestamp = None


    if __name__ == '__main__':
    main()
    main()
  2. @op op renamed this gist Sep 28, 2012. 1 changed file with 0 additions and 0 deletions.
  3. @op op created this gist Sep 28, 2012.
    25 changes: 25 additions & 0 deletions bash-history-to-zsh-history
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/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()