I’m working with a Mac and I want to compile and run my C files from the Terminal using a script. I’ve found a solution that apparently works quite well in Linux. Here is the article in Spanish (ayudasprogramacionweb.blogspot.c … 031640&m=1). It consists in two simple steps:
- You create a script in linux to compile and execute the source code in the Terminal and you store it in your Documents folder named as runC.sh.
#!/bin/bash
gnome-terminal -e "/bin/bash -c 'gcc $1 -o $2; $2; echo; read -p 'Pulse_intro_pasa_salir...'; exit; exec /bin/bash'; &"
- Through a Sublime Text Build System, you call this script by passing as parameters the name of the source file.
{
"cmd": "~/Documents/runC.sh ${file_path}/${file_name} ${file_path}/${file_base_name}"],
"shell": true
}
I’ve tried it in my Mac but as I expected it doesn’t work… Sublime Text give me an error: “gnome-terminal: command not found”.
I have the gcc compiler installed and working and I have given permissions to the script using chmod +x ./Documents/runC.sh
Could you help me to adapt it for Mac OS please? I’ve just started programming and I don’t know where to start to fix it…
Thank you very much!