Skip to content

Instantly share code, notes, and snippets.

@JackZielke
Last active February 20, 2022 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackZielke/0227b9dea61614c8089ed83620720a0b to your computer and use it in GitHub Desktop.
Save JackZielke/0227b9dea61614c8089ed83620720a0b to your computer and use it in GitHub Desktop.
Create grids to print graph paper
#!/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
@JackZielke
Copy link
Author

I had a program that would do this on the Apple //. Apparently, I felt this was missing from my life.

$ printgraph.sh
Usage: printgraph.sh <hex|square>
$ printgraph.sh hex
  _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _ 
_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \
 \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \
 \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \
 \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
etc.
$ printgraph.sh square
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_
etc.

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