History migration from ZSH to BASH

Ten post dostępny jest także w języku: pl

I’ve decided to move back from zsh to bash shell. It appeared that history migration is much bigger problem in this direction, mostly due to prefix added by zsh:

: 2145123543:0;git push origin master

Numbers are random, I’ve just wanted to show the example. I don’t know if it was created by my specific zsh config based on [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh] or if zsh does that by default. Fortunately there is this simple one-liner which will solve the problem and migrate your history in seconds:

cat ~/.zsh_history | sed 's/\:...........\:.\;//g' > ~/.bash_history

It removes the prefix and saves the file in bash default location. After reloading bash you’ll be able to search through your history. Another tip that I like to use in my computing is .inputrc modification which does the autocomplete based on the history on any stage of building the command, by using arrow keys “↑” and “↓”. You can find it in my configs repository and put it in your home directory.

Podobne wpisy