Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2018 19:57
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Migrate fish history to zsh shell (python 2.7)
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 =
if line and re.match('^when:', line):
meta, when = line.split('when: ', 1)
o.write(': %s:0;%s\n' % (when, fish_to_zsh(command)))
Copy link

it was really useful. thank you

Copy link

Thx a lot :)

Copy link

KTamas commented Nov 22, 2021


Copy link

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