From 91d3fc23c1591b331994181f99b23d613212b167 Mon Sep 17 00:00:00 2001 From: odrling Date: Sun, 2 Dec 2018 15:34:01 +0100 Subject: [PATCH] please insult me zsh --- .bash.command-not-found | 141 +++++++++++++++++++++++++++++++++++ .config/whipper/whipper.conf | 7 ++ .gitignore | 2 +- .zshrc | 2 + 4 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 .bash.command-not-found diff --git a/.bash.command-not-found b/.bash.command-not-found new file mode 100644 index 0000000..ad1acf9 --- /dev/null +++ b/.bash.command-not-found @@ -0,0 +1,141 @@ +print_message () { + + local messages + local message + + messages=( + "Boooo!" + "Don't you know anything?" + "RTFM!" + "Haha, n00b!" + "Wow! That was impressively wrong!" + "Pathetic" + "The worst one today!" + "n00b alert!" + "Your application for reduced salary has been sent!" + "lol" + "u suk" + "lol... plz" + "plz uninstall" + "And the Darwin Award goes to.... ${USER}!" + "ERROR_INCOMPETENT_USER" + "Incompetence is also a form of competence" + "Bad." + "Fake it till you make it!" + "What is this...? Amateur hour!?" + "Come on! You can do it!" + "Nice try." + "What if... you type an actual command the next time!" + "What if I told you... it is possible to type valid commands." + "Y u no speak computer???" + "This is not Windows" + "Perhaps you should leave the command line alone..." + "Please step away from the keyboard!" + "error code: 1D10T" + "ACHTUNG! ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN." + "Pro tip: type a valid command!" + "Go outside." + "This is not a search engine." + "(╯°□°)╯︵ ┻━┻" + "¯\_(ツ)_/¯" + "So, I'm just going to go ahead and run rm -rf / for you." + "Why are you so stupid?!" + "Perhaps computers is not for you..." + "Why are you doing this to me?!" + "Don't you have anything better to do?!" + "I am _seriously_ considering 'rm -rf /'-ing myself..." + "This is why you get to see your children only once a month." + "This is why nobody likes you." + "Are you even trying?!" + "Try using your brain the next time!" + "My keyboard is not a touch screen!" + "Commands, random gibberish, who cares!" + "Typing incorrect commands, eh?" + "Are you always this stupid or are you making a special effort today?!" + "Dropped on your head as a baby, eh?" + "Brains aren't everything. In your case they're nothing." + "I don't know what makes you so stupid, but it really works." + "You are not as bad as people say, you are much, much worse." + "Two wrongs don't make a right, take your parents as an example." + "You must have been born on a highway because that's where most accidents happen." + "If what you don't know can't hurt you, you're invulnerable." + "If ignorance is bliss, you must be the happiest person on earth." + "You're proof that god has a sense of humor." + "Keep trying, someday you'll do something intelligent!" + "If shit was music, you'd be an orchestra." + "How many times do I have to flush before you go away?" + ) + + # If CMD_NOT_FOUND_MSGS array is populated use those messages instead of the defaults + [[ -n ${CMD_NOT_FOUND_MSGS} ]] && messages=( "${CMD_NOT_FOUND_MSGS[@]}" ) + + # If CMD_NOT_FOUND_MSGS_APPEND array is populated append those to the existing messages + [[ -n ${CMD_NOT_FOUND_MSGS_APPEND} ]] && messages+=( "${CMD_NOT_FOUND_MSGS_APPEND[@]}" ) + + # Seed RANDOM with an integer of some length + RANDOM=$(od -vAn -N4 -tu < /dev/urandom) + + # Print a randomly selected message, but only about half the time to annoy the user a + # little bit less. + if [[ $((${RANDOM} % 2)) -lt 1 ]]; then + message=${messages[${RANDOM} % ${#messages[@]}]} + printf "\n $(tput bold)$(tput setaf 1)${message}$(tput sgr0)\n\n" + fi +} + +function_exists () { + # Zsh returns 0 even on non existing functions with -F so use -f + declare -f $1 > /dev/null + return $? +} + +# +# The idea below is to copy any existing handlers to another function +# name and insert the message in front of the old handler in the +# new handler. By default, neither bash or zsh has has a handler function +# defined, so the default behaviour is replicated. +# +# Also, ensure the handler is only copied once. If we do not ensure this +# the handler would add itself recursively if this file happens to be +# sourced multiple times in the same shell, resulting in a neverending +# stream of messages. +# + +# +# Zsh +# +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 () { + echo "zsh: command not found: $1" + return 127 + } +fi + +command_not_found_handler () { + print_message + orig_command_not_found_handler "$@" +} + + +# +# Bash +# +if function_exists command_not_found_handle; then + if ! function_exists orig_command_not_found_handle; then + eval "orig_$(declare -f command_not_found_handle)" + fi +else + orig_command_not_found_handle () { + echo "$0: $1: command not found" + return 127 + } +fi + +command_not_found_handle () { + print_message + orig_command_not_found_handle "$@" +} diff --git a/.config/whipper/whipper.conf b/.config/whipper/whipper.conf index a8c1954..fc19d0a 100644 --- a/.config/whipper/whipper.conf +++ b/.config/whipper/whipper.conf @@ -5,3 +5,10 @@ release = B901 defeats_cache = True read_offset = 6 +[drive:ASUS%20%20%20%20%3ASBW-06D2X-U%20%20%20%20%20%3A1.10] +vendor = ASUS +model = SBW-06D2X-U +release = 1.10 +defeats_cache = True +read_offset = 3 + diff --git a/.gitignore b/.gitignore index 503a3ef..61633e5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ Cache # zsh config files !/.zshrc !/.zprofile +!/.bash.command-not-found # git config file !/.gitconfig @@ -49,4 +50,3 @@ Cache !/.local !/.local/bin /.local/share - diff --git a/.zshrc b/.zshrc index a1040a5..aeb7cbf 100644 --- a/.zshrc +++ b/.zshrc @@ -5,6 +5,7 @@ if [ ! -f ~/.antigen/antigen.zsh ]; then curl -Ls git.io/antigen > ~/.antigen/antigen.zsh fi +source ~/.bash.command-not-found source ~/.antigen/antigen.zsh antigen use oh-my-zsh @@ -70,3 +71,4 @@ alias top="htop" alias ewatch="watch -cn 10 genlop -c" alias eupdate="sudo emerge --sync && sudo emerge -u1 portage && sudo emerge -uavD @world" alias dotmodules="dots submodule update --recursive --remote" +alias ytdl="youtube-dl"