Last active
March 17, 2020 17:15
-
-
Save eggplants/d44fff3ec3a7b89bce04053b3db3c94e to your computer and use it in GitHub Desktop.
kkcwx - kkcw(https://github.com/ryuichiueda/kkcw )のシェル版 より多くの入力に対応
This file contains hidden or 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
#!/bin/bash | |
######## | |
# help # | |
######## | |
function help(){ | |
cat<<"EOS" | |
kkcwx - 0.0.1 2019- | |
MIT License. | |
kkcwx is conversion (hiragana -> kanji) command. | |
This converts hiragana in the given sentence to kanji (or katakana). | |
Repository: https://gist.github.com/eggplants/d44fff3ec3a7b89bce04053b3db3c94e/ | |
Author: haruna <github.com/eggplants> | |
Usage: | |
kkcwx [text] | |
Examples: | |
kkcwx わたしは おいしい みせをしっている | |
kkcwx " | |
きみがよは | |
ちよにやちよに | |
さざれいしの | |
いわおとなりて | |
こけのむすまで | |
" | |
echo あかしろきいろ|kkcwx | |
kkcwx<<💩 | |
わたしまけましたわ | |
うんこです | |
💩 | |
Flags: | |
-h, --help help for align | |
EOS | |
} | |
########### | |
# PROCESS # | |
########### | |
function process(){ | |
for s in $(cat - );do | |
# kkcに入力, 出力をsedで整形 | |
echo "$s" | kkc | | |
sed -nr 's@[^<]*<([^>/]*)[^<]+@\1@gp' | |
done | |
} | |
######## | |
# main # | |
######## | |
function main(){ | |
[[ "$1" =~ --help|-h ]] && help | |
([[ "$#" > 0 ]] && echo "$@" || cat - )| process | |
exit 0 | |
} | |
main "$@" | |
exit 1 |
This file contains hidden or 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
#!/bin/bash | |
process(){ | |
for s in $(cat - );do | |
echo "$s"|kkc| | |
sed -nr ' | |
s@.:\s|>>\s@@g | |
s@<([^/]+)/[^>]+>@\1@gp' | |
done | |
} | |
main(){ | |
([[ "$#" > 0 ]] && echo "$@" || cat - )| process | |
} | |
main "$@" |
This file contains hidden or 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
# てすと | |
# 引数 | |
kkcwx わたしのあんぱんは おいしいのでさいこう さいきょうなんだよなぁ | |
# 改行入り引数 | |
kkcwx " | |
きみがよは | |
ちよにやちよに | |
さざれいしの | |
いわおとなりて | |
こけのむすまで | |
" | |
# パイプ | |
echo あかしろきいろ|kkcwx | |
# ヒアドキュメント | |
kkcwx<<💩 | |
わたしまけましたわ | |
うんこ、ぶりw | |
💩 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment