From b82bdbef4c7f9787473e77c36f320fdd4d1a05fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 31 Mar 2022 22:18:10 +0200 Subject: [PATCH] Clean up and refactor ragequit plugin --- ohmyzsh-custom/plugins/ragequit/README.md | 6 +- ohmyzsh-custom/plugins/ragequit/_fuck | 5 ++ ohmyzsh-custom/plugins/ragequit/fuck | 44 +++++++++++++ .../plugins/ragequit/ragequit.plugin.zsh | 64 +------------------ 4 files changed, 51 insertions(+), 68 deletions(-) create mode 100644 ohmyzsh-custom/plugins/ragequit/_fuck create mode 100644 ohmyzsh-custom/plugins/ragequit/fuck diff --git a/ohmyzsh-custom/plugins/ragequit/README.md b/ohmyzsh-custom/plugins/ragequit/README.md index 1634e37..c2efd3a 100644 --- a/ohmyzsh-custom/plugins/ragequit/README.md +++ b/ohmyzsh-custom/plugins/ragequit/README.md @@ -4,8 +4,6 @@ This plugin gives you control over your unresponsive programs and your uncontrolled rage by killing your programs with the magic words `fuck you` or `fuck off` for a more powerful response. -Demo: [URL to mp4]() - ## Instructions There are two main usage modes: @@ -19,11 +17,9 @@ If you have something else to say, arguments after the first two are ignored, so you can get out all the rage inside you in one nifty command: ```sh -$ fuck you chrome you freaking memory-devouring monster gaaaaaaa +$ fuck you chrome you stupid memory-devouring monster ``` -_NOTE: this does not represent my opinion about Chrome. I <3 Chrome :)_ - ## Thanks Original idea from [@namuol](https://github.com/namuol). diff --git a/ohmyzsh-custom/plugins/ragequit/_fuck b/ohmyzsh-custom/plugins/ragequit/_fuck new file mode 100644 index 0000000..2a89dd0 --- /dev/null +++ b/ohmyzsh-custom/plugins/ragequit/_fuck @@ -0,0 +1,5 @@ +#compdef fuck + +_arguments \ + ':who:(("you\:ask the process to quit" "off\:force quit the process"))' \ + ':process:_process_names -a' diff --git a/ohmyzsh-custom/plugins/ragequit/fuck b/ohmyzsh-custom/plugins/ragequit/fuck new file mode 100644 index 0000000..804555d --- /dev/null +++ b/ohmyzsh-custom/plugins/ragequit/fuck @@ -0,0 +1,44 @@ +#!/usr/bin/env zsh + +local action="$1" +local process="$2" + +# Force kill if 'fuck off' +local -a flags +case "$action" in + off) flags+=("-9") ;; + you) : ;; +esac + +local -A flip_table +flip_table=( + "a" "ɐ" "b" "q" "c" "ɔ" "d" "p" "e" "ǝ" "f" "ɟ" "g" "ƃ" + "h" "ɥ" "i" "ı" "j" "ɾ" "k" "ʞ" "l" "|" "m" "ɯ" "n" "u" + "o" "o" "p" "d" "q" "b" "r" "ɹ" "s" "s" "t" "ʇ" "u" "n" + "v" "ʌ" "w" "ʍ" "x" "x" "y" "ʎ" "z" "z" "A" "ɐ" "B" "q" + "C" "ɔ" "D" "p" "E" "ǝ" "F" "ɟ" "G" "ƃ" "H" "ɥ" "I" "ı" + "J" "ɾ" "K" "ʞ" "L" "|" "M" "ɯ" "N" "u" "O" "o" "P" "d" + "Q" "b" "R" "ɹ" "S" "s" "T" "ʇ" "U" "n" "V" "ʌ" "W" "ʍ" + "X" "x" "Y" "ʎ" "Z" "z" "," "'" "'" "," '"' "," ";" "؛" + "." "˙" "(" ")" "{" "}" "[" "]" "⁅" "⁆" "<" ">" "‿" "⁀" + "_" "‾" "?" "¿" '!' "¡" "∴" "∵" "\r" "\n" +) + +local char flipped_process +# split into array and reverse it +# replace each character with its flipped version, unless there isn't one +for char in ${(s::Oa)process}; do + flipped_process+="${flip_table[$char]:-$char}" +done + +# Kill the process and print the pertinent message +if command killall $flags -- "$process" &>/dev/null; then + echo " + (╯°□°)╯︵$flipped_process +" +else + echo " +(; ̄Д ̄) . o O( It's not very effective... ) +" + return 1 +fi diff --git a/ohmyzsh-custom/plugins/ragequit/ragequit.plugin.zsh b/ohmyzsh-custom/plugins/ragequit/ragequit.plugin.zsh index 2f00bc8..902dd2d 100644 --- a/ohmyzsh-custom/plugins/ragequit/ragequit.plugin.zsh +++ b/ohmyzsh-custom/plugins/ragequit/ragequit.plugin.zsh @@ -1,63 +1 @@ -fuck() { - emulate -L zsh - local action="$1" - local process="$2" - - # Force kill if 'fuck off' - local -a flags - case $action in - off) flags+=("-9") ;; - you) : ;; - esac - - local -A flip_table - flip_table=( - "a" "ɐ" "b" "q" "c" "ɔ" "d" "p" "e" "ǝ" "f" "ɟ" "g" "ƃ" - "h" "ɥ" "i" "ı" "j" "ɾ" "k" "ʞ" "l" "|" "m" "ɯ" "n" "u" - "o" "o" "p" "d" "q" "b" "r" "ɹ" "s" "s" "t" "ʇ" "u" "n" - "v" "ʌ" "w" "ʍ" "x" "x" "y" "ʎ" "z" "z" "A" "ɐ" "B" "q" - "C" "ɔ" "D" "p" "E" "ǝ" "F" "ɟ" "G" "ƃ" "H" "ɥ" "I" "ı" - "J" "ɾ" "K" "ʞ" "L" "|" "M" "ɯ" "N" "u" "O" "o" "P" "d" - "Q" "b" "R" "ɹ" "S" "s" "T" "ʇ" "U" "n" "V" "ʌ" "W" "ʍ" - "X" "x" "Y" "ʎ" "Z" "z" "," "'" "'" "," '"' "," ";" "؛" - "." "˙" "(" ")" "{" "}" "[" "]" "⁅" "⁆" "<" ">" "‿" "⁀" - "_" "‾" "?" "¿" '!' "¡" "∴" "∵" "\r" "\n" " " " " - ) - - local reversed_process flipped_process char - # split into array and reverse it - reversed_process=(${(s::Oa)process}) - # replace each character with its flipped version, unless there isn't one - for char ($reversed_process); do - flipped_process+=${flip_table[$char]:-$char} - done - - # Kill the process and print the pertinent message - if command killall $flags "$process" >/dev/null 2>&1; then - cat <<-EOF - - (╯°□°)╯︵$flipped_process - - EOF - else - cat <<-'EOF' - - (; ̄Д ̄) . o O( It's not very effective... ) - - EOF - fi -} - -_fuck() { - local expl - local curcontext="$curcontext" state line - local -A opt_args - - _arguments -C ':who:(you off)' '*:process:->process' - - case $state in - process) _process_names -a ;; - esac -} - -compdef _fuck fuck +autoload -Uz fuck