Initialize a p5.js project from the command line! π¦
This script creates all the necessary files for a p5.js project, including an index.html, sketch.js, and style.css file. You can choose a directory to create the p5 project in (default: current directory, aka .), and the name of the sketch (default: sketch).
curl -O https://raw.githubusercontent.com/codevogel/mkp5/refs/heads/main/mkp5
chmod +x mkp5
./mkp5 [directory] [sketch name]βΉοΈ This assumes you are running Linux or Windows Subsystem for Linux (WSL).
-
git clonethis repository, or download themkp5file directly. -
Make the file executable:
chmod +x the/path/to/mkp5- (Optional): Add the file to your PATH. For example, when using bash:
echo "export PATH=\$PATH:/the/path/to/mkp5" >> ~/.bashrcDon't forget source your .bashrc (or simply restart your terminal).
source ~/.bashrc- If you completed step 3, you can now run
mkp5from anywhere!
mkp5 [directory] [sketch name]If you didn't complete step 3, you can run the script like this:
/the/path/to/mkp5 [directory] [sketch name](Note that if you did not complete step 3, and are trying to run mkp5 from the current directory, you'll have to prepend ./ to the script name.)
./mkp5 [directory] [sketch name]mkp5Creates index.html, sketch.js, and style.css files in the current directory.
mkp5 my-p5-projectCreates index.html, sketch.js, and style.css files in ./my-p5-project
mkp5 my-p5-project my-sketchCreates index.html, my-sketch.js, and style.css files in ./my-p5-project
Feel free to fork this repository and submit a PR if you have any improvements, features or bug fixes!