Cool Experiment With Opensource Project Viu

Darshak sorathiya
2 min readOct 25, 2020

We all love memes. We also love to share some insulting and funny memes with our friends. I have done one cool experiment with the zsh terminal in my Mac using the opensource project Viu where the terminal will be the user’s friend. Excited to Know more about Experiment? Cool. Let’s know more about the Experiment.

The Core Idea is to show insulting memes to the User whenever the User enters the wrong command in the terminal. For showing memes in a zsh terminal, I used opensource project Viu. Viu is a small command-line application to view images and gifs from the terminal written in Rust. Using Viu and one script I have configured my zsh terminal which will show insulting memes whenever I will give the wrong command to my terminal. Want to try the same in your terminal? You can set up in your mac zsh terminal by following the below steps.

Steps to follow for Setting up insulter using memes in your mac zsh terminal

  1. Download your favorite insulting meme in your local.
  2. Install Viu in your zsh terminal from here.
  3. Go to /etc directory. Make one file bash.insult and paste the following content into it. Replace sampleFilePath by file path of your local meme file.

function_exists () {
declare -f $1 > /dev/null
return $?
}
if function_exists command_not_found_handler; then
if ! function_exists orig_command_not_found_handler; then
eval “orig_$(declare -f command_not_found_handler)”
fi
else
orig_command_not_found_handler () {
printf “zsh: command not found: %s\\n” “$1” >&2
return 127
}
fi
command_not_found_handler () {
viu -h 30 -w 50 sampleFilePath
orig_command_not_found_handler “$@”
}

4. Go to the Home directory. Open .zshrc file and add the below content to your .zshrc file

if [ -f /etc/bash.insult ]; then
. /etc/bash.insult
fi

5. Run source .zshrc command and restart terminal. Congrats! Your Terminal is ready to show insulting meme while you will enter the wrong command.

Here is a Demo of this cool functionality

Thank You For Reading!

--

--