macoscoderunner

CodeRunner 4.0.3 (Mac software) - how to execute program in Terminal window?


I use CodeRunner on Mac which is a programming IDE for multiple programming languages, not Code Runner vor Visual Studio!

When I execute a program, inputs and outputs will be shown inside of this IDE, not in an external Terminal window.

The problem is when I set the cursor to a specific position on the screen, it will not be shown correctly. Only when I open a Terminal window and start the program from there, inputs and outputs will be shown at the right positions.

Is there a way to open an external Terminal window from CodeRunner directly and run the program there? It is ok when I have to close this window manually after the program finished.


Solution

  • Okay, so finally I solved this ! Steps : Open Script Editor app. Create new Script and paste this code :

    on run argv
        tell application "Terminal" to activate
        tell application "Terminal" to do script "cd ~" in selected tab of the front window
        tell application "Terminal" to do script "cd " & item 2 of argv in selected tab of the front window
        tell application "Terminal" to do script "clear" in selected tab of the front window
        tell application "Terminal" to do script "bash " & item 1 of argv in selected tab of the front window
    end run
    

    save this file inside the folder in which you are coding/ or provide path while executing. This will look like this : Script Editor app in MacOS I saved it in /Users/aayush/Downloads folder as automated_run. This script editor app will save this script as automated_run.scpt.

    Now open CodeRunner App. Select Run Settings..., Now Copy the command written in Run Command field before the $filename. [For example, If I am coding in shell scripting then I will copy the bash from the command bash $filename; for python, I will copy python3 from python3 $filename] Copy command from run command in coderunner Then open the script editor and see the line number 6 and paste your command in place of "bash ". Here I am coding in shell scripting so that as per my requirement, I used 'bash ' here. Then in CodeRunner, Paste this code in place of run command in Run Setting... :

    osascript automated_run.scpt $filename $PWD
    

    It will look like this now : run command in coderunner Run settings... Now you have two options : you can make this run command as default or you can use this as temporary. That is your choice. now close this window. and run any sample program to check this functionality which we just implemented. Let's run sample program : I made a sample file named helloaayush.sh and stored that in /Users/aayush/Downloads CodeRunner file helloaayush.sh screenshot

    Now after pressing the Run button : A new terminal window will open and your code output will be visible there. terminal window displaying your output of your code

    Let me know if something is unclear :)