If you use
zsh for your shell very occasionally you may find the following message appearing indicating a corrupt history file. This is normally after a reboot.
zsh: corrupt history file /home/george/.zsh_history
This prevents searching back through the history with
CTRL+R and editing previous commands with
To fix it run the following commands
cd ~ mv .zsh_history .zsh_history_bad strings .zsh_history_bad > .zsh_history fc -R .zsh_history
Once this happened more than twice I made a script to fix the issue. The following is saved in my
~/bin folder as
zsh_history_fix and this folder is in my
#!/usr/bin/env sh # George Ornbo (shapeshed) http://shapeshed.com # License - http://unlicense.org # # Fixes a corrupt .zsh_history file mv ~/.zsh_history ~/.zsh_history_bad strings .zsh_history_bad > .zsh_history fc -R ~/.zsh_history rm ~/.zsh_history_bad
Now if I see the
zsh: corrupt history file error again I just run the command get back to work.
If you’d like the script you can download it directly from Github, put it somewhere in your
$PATH and make it executable.
cd ~/bin # or somewhere in your $PATH wget https://github.com/shapeshed/dotfiles/blob/master/bin/zsh_history_fix chmod +x zsh_history_fix
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Listening to BBC Radio with mpv
The BBC publishes high quality 320 kbps HLS AAC streams that can be used to listen to radio from the command-line using mpv. Here are the URLs and some aliases to start listening quickly.
Vim: So long Pathogen, hello native package loading
Vim 8 added a native way to load third-party packages. This means, for me at least, there is no longer any need to use a third party plugin helper like Pathogen.
Linux and Unix more command tutorial with examples
Tutorial on using more, a UNIX and Linux command for viewing the contents of a file or files one screen at a time. Examples of viewing a file, viewing multiple files, searching using regular expressions and opening the file in a text editor.