Created
November 27, 2020 07:42
-
-
Save learnitall/477d18cbd5d12da0c312cc7738e34ae2 to your computer and use it in GitHub Desktop.
Annoying bashrc snippet that makes using the terminal horrendous. Place this file right at the tail end of a users' bashrc to give them 15 minutes of puzzling entertainment. Please contribute if you have ideas.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://unix.stackexchange.com/questions/250713/modify-all-bash-commands-through-a-program-before-executing-them | |
# $BASH_COMMAND contains the command bash is executing | |
# return 0 to allow $BASH_COMMAND to be evaled after function return | |
# return 1 to tell bash not to eval $BASH_COMMAND after function return | |
# requires figlet, cowsay and sl to be installed | |
shopt -s extdebug | |
preexec_invoke_exec () { | |
# do nothing if completing | |
[ -n "$COMP_LINE" ] && return | |
# do nothing if executing a command to issue a prompt | |
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return | |
if [ -n "$BASH_COMMAND" ]; then | |
echo "$BASH_COMMAND" | figlet | cowsay -n | |
fi | |
# This is the graphical terminal on a raspberry pi, change as needed. | |
# CHANGEME | |
lxterminal | |
# COWS | |
if [[ "$BASH_COMMAND" =~ man ]]; then | |
man cowsay | |
return 1; | |
elif [[ "$BASH_COMMAND" =~ lxterminal ]]; then | |
return 0; | |
elif [[ "$BASH_COMMAND" =~ which|alias|vim|vi|nano|gedit|emacs|apt|sudo|perl|zsh|sh|rm|mv|cp ]]; then | |
echo "nah" | |
return 1; | |
elif [[ "$BASH_COMMAND" =~ ls|pwd|cd|dir|cat|sed ]]; then | |
sl | |
figlet choo choo | cowsay -n | |
elif [[ "$BASH_COMMAND" =~ exit ]]; then | |
figlet please dont leave | cowsay -gn | |
return 1; | |
fi | |
return 0; | |
} | |
trap preexec_invoke_exec DEBUG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment