Animated gifs are a great way to quickly demonstrate small tasks on the screen. Videos are an overkill and making quality gifs is often quite a pain. I often use LICEcap to created animated gifs and it works great. However, it isn't exactly hacker friendly!
I prefer to use his video-to-gif_osx.sh script and it works great.
The only issue I faced on my Mac was related to imagemagick. Few png libs were missing and others seemed to face the other problem with their ImageMagick installations as discussed in this thread => ImageMagick package missing PNG? · Issue #14325 · Homebrew/homebrew
A full re-installation using this code worked perfectly for me:
sudo brew install imagemagick --build-from-source
sh sudo chmod 777 video_to_gif_osx.sh to make the script executable. And then encode a screen recording done with QuickTime to the animated gif using
sh ./video_to_gif_osx.sh test.mov
And, here is a outputted gif :-)