Last active
February 20, 2022 05:44
-
-
Save JackZielke/0227b9dea61614c8089ed83620720a0b to your computer and use it in GitHub Desktop.
Create grids to print graph paper
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
#!/bin/bash | |
COLS=`tput cols` | |
ROWS=$[`tput lines`-1] | |
function printgraph() { | |
if [ $TYPE == hex ]; then | |
COUNT1=$[COLS/4] | |
COUNT2=$[ROWS/2] | |
else | |
COUNT1=$[COLS/2] | |
COUNT2=$ROWS | |
fi | |
j=0 | |
while [ $j -lt $COUNT1 ]; do | |
if [ $TYPE == hex ]; then | |
echo -n ' _ ' | |
else | |
echo -n ' _' | |
fi | |
j=$[j+1] | |
done | |
echo | |
i=0 | |
j=0 | |
while [ $i -lt $COUNT2 ]; do | |
while [ $j -lt $COUNT1 ]; do | |
if [ $TYPE == hex ]; then | |
echo -n '_/ \' | |
else | |
echo -n '|_' | |
fi | |
j=$[j+1] | |
done | |
echo | |
j=0 | |
while [ $j -lt $COUNT1 ]; do | |
if [ $TYPE == hex ]; then | |
echo -n ' \_/' | |
fi | |
j=$[j+1] | |
done | |
if [ $TYPE == hex ]; then | |
echo | |
fi | |
j=0 | |
i=$[i+1] | |
done | |
} | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <hex|square>" | |
echo | |
exit 1 | |
fi | |
case $1 in | |
"hex") | |
TYPE=hex | |
printgraph | |
;; | |
"square") | |
TYPE=square | |
printgraph | |
;; | |
*) | |
echo "ERROR: I don't know how to $1" | |
echo | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a program that would do this on the Apple //. Apparently, I felt this was missing from my life.