Last active
August 25, 2022 04:49
-
-
Save kickbase/d65bea6f641bf7045e850bf011aca0b4 to your computer and use it in GitHub Desktop.
[ Python ] command line sudden death tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! 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") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[ usage ]
Write the following code in .zshrc
$sd foo bar
following text will be copied to the clipboard
_人人人人人_
> foo bar <
 ̄Y^Y^Y^Y^ ̄