Note: This document is a work in progress. You can help improve it.

Super amazing animated gif prompt

We all like funny animated gifs, right?

We all like personalizing our shell prompts, right?

So lets do both!

Demo

demo

Requirements

  • iTerm2 version 2.9 or later -- currently requires a test version
  • zsh (because setting an animated gif in the prompt in bash works, but is unreasonably slow)
  • imgcat (iTerm2 script for displaying images)
  • An animated gif of your own
  • Awesomeness

Process

To speed up our prompt we will pre-process our animated gif (using the imgcat utility) into the format iTerm requires and save the output somwehere. I choose ~/.zsh/images/prompt.base64 or something similar.

imgcat /path/to/funny.gif > ~/.zsh/images/prompt.base64`

Update your prompt in your ~/.zshrc to cat out the preprocessed file to the display. Here is an example of mine:

animate_if_error()
{
if [[ $? -ne 0 ]]; then
PROMPT="$(cat ~/.zsh/images/prompt.base64)
$ "
else
PROMPT="$ "
fi
}
precmd_functions+=animate_if_error

Now any time a command fails my prompt is updated with a hillarious animated gif (in reality, like all good zsh-ers my prompt is way more complex)