Skip to content

Commit

Permalink
Clean up and refactor ragequit plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornella committed Mar 31, 2022
1 parent 4fbe69a commit b82bdbe
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 68 deletions.
6 changes: 1 addition & 5 deletions ohmyzsh-custom/plugins/ragequit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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).
Expand Down
5 changes: 5 additions & 0 deletions ohmyzsh-custom/plugins/ragequit/_fuck
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#compdef fuck

_arguments \
':who:(("you\:ask the process to quit" "off\:force quit the process"))' \
':process:_process_names -a'
44 changes: 44 additions & 0 deletions ohmyzsh-custom/plugins/ragequit/fuck
Original file line number Diff line number Diff line change
@@ -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
64 changes: 1 addition & 63 deletions ohmyzsh-custom/plugins/ragequit/ragequit.plugin.zsh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b82bdbe

Please sign in to comment.