You are not logged in.

#1 2014-06-16 20:27:13

xero
Member
From: ~/
Registered: 2014-04-02
Posts: 86
Website

suggestions for improvement on an ansi art bash script

so i've been trying to hone my bash skills recently. 

this weekend i made an ansi art version of ryu from the nintendo nes game ninja gaiden. after making a colored version i wanted to echo it in bash. after a little while i came up with a little script that measures your terminal size and "pads" the image evenly with periods on either side. it also has a few options for rendering types, version info, help, etc.

BqQ9bzeCYAArfSe.png:small

tl;dr

i'd like some feedback on my bash code. suggestions on what i could have done better, things to make the script smaller, more cross compatible, etc. here's the code: https://github.com/syntax-samurai/ryu/blob/master/ryu

feel free to answer in the thread or fork the project on github. this project is just for fun and learning.
thanks in advance.


▬▬ι═══════ﺤ
http://git.io/.files

Offline

#2 2014-06-16 20:36:02

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: suggestions for improvement on an ansi art bash script

(A quick correction: I think you mean ASCII art.) smile

EDIT: (A quick correction to me: Apparently there's such a thing as ANSI art. TIL) lol

Last edited by drcouzelis (2014-06-16 20:37:30)

Offline

#3 2014-06-16 20:44:24

xero
Member
From: ~/
Registered: 2014-04-02
Posts: 86
Website

Re: suggestions for improvement on an ansi art bash script

drcouzelis wrote:

(A quick correction: I think you mean ASCII art.) smile

EDIT: (A quick correction to me: Apparently there's such a thing as ANSI art. TIL) lol

yeah. it's a very subtle difference. they're both methods of text based art. but if you draw using the `box drawing characters` and call it ASCII, the scene jumps down your throat ;D


▬▬ι═══════ﺤ
http://git.io/.files

Offline

#4 2014-06-17 19:38:00

Saint0fCloud
Member
Registered: 2009-03-31
Posts: 137

Re: suggestions for improvement on an ansi art bash script

Looks fine to me, although the last `exit` is superfluous. If you wanted to get rid of all those `echo` calls and the extra version of your image, you could use a heredoc. To get colors in the heredoc just throw the escape codes into functions that check whether '--grey' or '--color' is set and use command substitution.

Offline

Board footer

Powered by FluxBB