Skip to content

Instantly share code, notes, and snippets.

@hnykda
Created February 21, 2018 21:26
Show Gist options
  • Save hnykda/61032fdd08c79a592504167acb790fab to your computer and use it in GitHub Desktop.
Save hnykda/61032fdd08c79a592504167acb790fab to your computer and use it in GitHub Desktop.
Quick and dirty conversion of ZSH history into fish
# run as `python conver.py <path-to-your-zsh-history-file>
import sys
output_file = 'fish_converted_history'
zsh_history_file = sys.argv[1]
with open(zsh_history_file, 'r', errors='ignore') as ifile:
result = []
for cmd in ifile:
try:
_tims, sc = cmd.rstrip('\n').split(';', 1)
tims = _tims[2:].split(":")[0]
result.append('- cmd: {}\n when: {}'.format(sc, tims))
except:
print(f'invalid {cmd}')
with open(output_file, 'w') as ofile:
ofile.write('\n'.join(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment