I made a mini compiler to help compile C code easier on linux machines with bash
#!/bin/bash
function project_menu {
header
echo "Edit project: $1"
dir
echo "1) New file"
echo "2) Edit file"
echo "3) Compile file"
echo "4) Run Project"
echo "5) Compile & Run Project"
echo "6) Back to main menu"
read opt
if [ "$opt" = "1" ]; then
new_file
elif [ "$opt" = "2" ]; then
edit_file
elif [ "$opt" = "3" ]; then
compile
elif [ "$opt" = "4" ]; then
run
elif [ "$opt" = "5" ]; then
compile_run
elif [ "$opt" = "6" ]; then
cd ..
return
else
clear
header
echo "Bad Option"
pause "Press enter"
project_menu $1
fi
project_menu $1
}
function compile_run {
header
echo "What file would you like to compile and then run?"
printf ">"
read FILENAME
echo "Compiler >>"
echo
gcc -o $FILENAME $FILENAME.c
echo
echo "Done!"
echo "<< Compiler"
pause "Press enter to run"
echo "Process Output >>"
echo
./$FILENAME
echo
echo "<< Process Finished"
pause "Press enter"
}
function run {
header
echo "What file would you like to run?"
printf ">"
read FILENAME
echo "Process Output >>"
echo
./$FILENAME
echo
echo
echo "<< Process finished"
pause "Press enter"
}
function compile {
header
echo "What file would you like to compile?"
printf ">"
read FILENAME
echo "Compiling.."
gcc -o $FILENAME $FILENAME.c
echo "Done!"
pause "Press enter"
}
function edit_file {
header
echo "What file would you like to open?"
printf ">"
read FILENAME
pico $FILENAME.c
}
function new_project {
header
echo "What would you like to name your new project?"
printf ">"
read FILENAME
mkdir $FILENAME
cd $FILENAME
project_menu "$FILENAME"
}
function edit_project {
header
echo "What is the name of the project you would like to open?"
printf ">"
read FILENAME
cd $FILENAME
project_menu "$FILENAME"
}
function new_file {
header
echo "What would you like to name your new file?"
printf ">"
read FILENAME
pico $FILENAME.c
}
function pause {
read -p "$*"
}
function header {
clear
echo "########################################"
echo "# C/C++ Compiler - M4trixSh4d0w #"
echo "########################################"
}
function menu {
header
echo "1) Create New Project"
echo "2) Edit Project"
echo "3) Quit"
printf ">"
read opt
if [ "$opt" = "1" ]; then
new_project
elif [ "$opt" = "2" ]; then
edit_project
elif [ "$opt" = "3" ]; then
clear
exit 0
else
clear
header
echo "Bad Option"
pause "Press enter"
menu
fi
menu
}
menu