Easy Runner
This extension helps you running custom commands for individual file types.
This way you can run the commands as you would run it by typing command manually.
This translates to more customizable, more control and more flexibility...
To run a code
Before using this extension make sure that associated executor is available in the PATH
variable.
Otherwise you'll have to define the full path in the command.
- Press the button
- Or press
Ctrl + Enter
or Ctrl + R
to run in the integrated terminal
- Or press
Ctrl + Alt + Enter
or Ctrl + Alt + R
to run in a separate window (Windows Only)
Note: If the run icon does not appear, click inside the text editor and it should
Features
Extension Settings
This extension has four settings.
Open the settings page in your visual studio code and search easyRun
to view them all.
Or you can view them from extensions.
Or add those in settings.json
file
Setting: File Types
easyRunner.fileTypes
in settings.json
This is where you can set the commands for different file types.
It accepts an Object<string, string>
as value in following format:
{
".c" :"command to execute for `C` files",
".cpp" :"command to execute for `C++` files",
".js" :"command to execute for `JavaScript` files",
".py" :"command to execute for `Python` files"
}
Available variables are:
* `${filePath}` : Complete file path with drives (`C:\Users\You\js\main.js` in windows) and (`/home/you/js/main.js` in Unix)
* `${fileDir}` : File directory path with drives (`C:\Users\You\js` in windows) and (`/home/you/js` in Unix)
* `${fileBaseName}` : File name (`main.js` in this case)
* `${fileNameNoExt}` : File name without extension. Suppose your file path is `C:\Users\You\js\main.js`, then it will be translated to `main`
* `${workSpacePath}` : Workspace path with drives I.e `C:\Users`
* `${fileDirWorkSpace}` : File directory path after workspace (If wokspace path is C:\Users then this will return `You\js`
An example command can be:
gcc ./${fileDirWorkSpace}/${fileBaseName} -o ./${fileDirWorkSpace}/${fileNameNoExt} && ./${fileDirWorkSpace}/${fileNameNoExt}
Now, suppose you workspace path
is: D:\Coding\C\TestProject
and the file path
(the one you're running) is D:\Coding\C\TestProject\core\take_input.c
In this case, this above command will be translated to:
gcc .\core\take_input.c -o .\core\take_input && .\core\take_input.c
Terminals cwd will always be the workspace's path. And if the file is outside of workspace then the files directory.
So, you don't need to specify the files complete path. We will take care of this inshallah.
An example of what the value can be
{
".c" :"gcc ./${fileDirWorkSpace}/${fileBaseName} -o ./${fileDirWorkSpace}/${fileNameNoExt} && ./${fileDirWorkSpace}/${fileNameNoExt}",
".cpp" :"gcc ./${fileDirWorkSpace}/${fileBaseName} -o ./compiled/tmp && ./compiled/tmp",
".js" :"node ./${fileDirWorkSpace}/${fileBaseName}",
".py" :"python ./${fileDirWorkSpace}/${fileBaseName}"
}
***
### ***Setting:*** `Clear On Run`
_`easyRunner.clearOnRun`_ in `settings.json`
***
Wheather or not to clear the terminal before running commands.
If you don't like to let your terminal get dirty just set this option to true
easyRun.clearOnRun
: true
or false
Setting: Execute Command In One Line
easyRun.executeCommandInOneLine
in settings.json
Set how commands should be exectuted. (One line or broken into pieces for every `&&`)
This setting will only be applied for the commands that has ` && ` in it.
I.e:
```
gcc ./${fileDirWorkSpace}/${fileBaseName} -o ./${fileDirWorkSpace}/${fileNameNoExt} && ./${fileDirWorkSpace}/${fileNameNoExt}
```
easyRun.executeCommandInOneLine
: true
or false
If set false
then the previous command will be broken down and and executed in following way:
gcc ./${fileDirWorkSpace}/${fileBaseName} -o ./${fileDirWorkSpace}/${fileNameNoExt}
After completion of running the above the following will be executed:
./${fileDirWorkSpace}/${fileNameNoExt}
This options is helpful for windows users because in some cases &&
results to an error.
Setting: Run In Separate Window
easyRun.runInSeparateWindow
in settings.json
How button should run code.
true
or false
If set true
button will run code in a separate window.
Known Issues
Separate terminal may not work for the linux or mac users.
If you find any then please consider texting me in Instagram or Twitter
Release Notes
- Default setting of running single command changed to false
- Added a progress bar when running in separate window is true
- File will be now saved automatically on run
- Added support for opening in separate window
- Added key bindings for running code
- Probable bug fixed
- Added option in editor context menu
Added option to set commands in multiline
Added directory recognition for files from outside of workspace
Initial release
Enjoy!