Skip to content

Instantly share code, notes, and snippets.

@kickbase
Last active August 25, 2022 04:49
Show Gist options
  • Save kickbase/d65bea6f641bf7045e850bf011aca0b4 to your computer and use it in GitHub Desktop.
Save kickbase/d65bea6f641bf7045e850bf011aca0b4 to your computer and use it in GitHub Desktop.
[ Python ] command line sudden death tool
#! python3
# -*- coding: utf-8 -*-
import math
import pyperclip
import unicodedata
import sys
def len_count(text):
count = 0
for c in text:
count += 2 if unicodedata.east_asian_width(c) in "FWA" else 1
return count
def main(s):
num = math.floor(len_count(s) / 2)
return f"_{'人' * (num + 2)}_\n> {s} <\n ̄Y^{'Y^' * num} ̄"
if __name__ == "__main__":
args = sys.argv
if 2 <= len(args):
pyperclip.copy(main(" ".join(args[1:])))
else:
print("Arguments are too short")
@kickbase
Copy link
Author

[ usage ]

Write the following code in .zshrc

alias sd="python3 ~/sudden_death.py"

$sd foo bar

following text will be copied to the clipboard

_人人人人人_
> foo bar <
 ̄Y^Y^Y^Y^ ̄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment