Created
February 21, 2018 21:26
-
-
Save hnykda/61032fdd08c79a592504167acb790fab to your computer and use it in GitHub Desktop.
Quick and dirty conversion of ZSH history into fish
This file contains 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
# 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