Forked from mateuspontes/migrate-fish-history-to-zsh.py
Created
June 9, 2020 16:13
-
-
Save mksvdmtr/d2d73a1e5698bc404e472c81ed3822ce to your computer and use it in GitHub Desktop.
Migrate fish history to zsh shell (python 2.7)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
def fish_to_zsh(cmd): | |
return (cmd.replace('; and ', '&&') | |
.replace('; or ', '||')) | |
with open(os.path.expanduser('~/.zsh_history.test'), 'a') as o: | |
with open(os.path.expanduser('~/.local/share/fish/fish_history')) as f: | |
for line in f: | |
line = line.strip() | |
if line and re.match('^- cmd:', line): | |
meta, command = line.split('- cmd: ', 1) | |
line = f.next().strip() | |
if line and re.match('^when:', line): | |
meta, when = line.split('when: ', 1) | |
o.write(': %s:0;%s\n' % (when, fish_to_zsh(command))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment