Skip to content

Instantly share code, notes, and snippets.

@jpouellet
Forked from SietsevanderMolen/fuckyou.plugin.zsh
Last active November 10, 2016 02:16
Show Gist options
  • Save jpouellet/854b1bf993abd4375f5673c3a200d16b to your computer and use it in GitHub Desktop.
Save jpouellet/854b1bf993abd4375f5673c3a200d16b to your computer and use it in GitHub Desktop.
Table flip all the strings!
#!/usr/bin/env zsh
function flipstr() {
local chars='_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890()[]{}<>'
local flipped='¯ɐqɔpǝɟɓɥıɾʞlɯuodbɹsʇnʌʍxʎz∀𐐒ƆᗡƎℲ⅁HIſ⋊⅂WNOԀΌᴚS⊥∩ΛMX⅄Z⇂ᄅƐㄣގ9ㄥ860)([]}{><'
local string="$*"
local newstring=''
for ((i = ${#string}; i > 0; i--)); do
#newstring+=${flipped[${chars[(i)${string[$i]}*]}]}
char=${string[$i]}
flipchar=${flipped[${chars[(i)${char}*]}]}
newstring+=${flipchar:-${char}}
done
printf %s "$newstring"
}
flip() {
echo "(╯°□°)╯︵ $(flipstr "${@:-┻━┻}")"
}
unflip() {
echo "${*:-┬──┬} ノ( ゜-゜ノ)"
}
# so sourcing only grabs fns, but execing flips tables
if [[ $# -ne 0 ]]; then
flip "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment