Recently I started to move from McFly to Atuin and wanted to quickly import McFly history.
But atuin
didn't include a method to import Mcfly history.
So here is my short procedure:
McFly --> Zsh history format --> Zsh History (merge) --> Atuin import:
For ZSH
# Make sure McFly is still your history manager
# Dump `mcfly` history
mcfly dump > ./mcfly-hist.json
# Now convert the json file with JQ and convert
# Pretty sure there is a faster way to do this, but I am lazy :), it works, takes few seconds for my 10k hist
jq -r 'sort_by(.when_run) | .[] | [.when_run, .cmd]|@tsv' ./mcfly-hist.json | while IFS=$'\t' read -r when_run cmd; do printf ": %s:0;%s\n" "$(date -d $when_run +%s)" "$cmd"; done >| /tmp/hist_mcfly
# Stop current Z-shell's history
fc -p # Turns on memory hist
# Concat Exported history to ZSH history
# Make a backup PLEASE!
cp ~/.zsh_history{,_bak}
# Replace the current history
cat /tmp/hist_mcfly ~/.zsh_history_bak | sort | uniq >| ~/.zsh_history
# Assuming your shell didn't crap out, import into Atuin
atuin import zsh
# Exit Or CTRL+D to exit current shell which has in-mem hist
exit
For Bash
# Make sure McFly is still your history manager
# Dump `mcfly` history
mcfly dump > ./mcfly-hist.json
# Now convert the json file with JQ and convert
# Pretty sure there is a faster way to do this, but I am lazy :), it works, takes few seconds for my 10k hist
jq -r 'sort_by(.when_run) | .[] | [.cmd]|@tsv' >| /tmp/hist_mcfly
# Stop current Bash history
set +o history # Disables history
# Concat Exported history to ZSH history
# Make a backup PLEASE!
cp ~/.bash_history{,_bak}
# Replace the current history
cat /tmp/hist_mcfly ~/.bash_history_bak | sort | uniq >| ~/.bash_history
# Assuming your shell didn't crap out, import into Atuin
atuin import bash
set -o history # enables history