This repository contains a set of scripts that allow you to execute source code files in various programming languages, including C, C++, Java, JavaScript, Lua, and Python. The scripts work on both Linux and Windows operating systems. Since they are shell scripts, they should work on macOS as well. However, this guide currently focuses on Windows and Linux environments.
-
Create a folder named
myscripts
in your home directory:mkdir ~/myscripts
-
Copy the
run.sh
andrunf.sh
scripts into themyscripts
folder after downloading them from this repository. -
Add the following aliases to your shell configuration file (e.g.,
.bashrc
or.zshrc
):alias run="bash ~/myscripts/run.sh" alias runf="bash ~/myscripts/runf.sh"
-
If you encounter any execution permission errors, make the scripts executable:
chmod +x ~/myscripts/run.sh chmod +x ~/myscripts/runf.sh
-
Source your shell configuration file to apply the changes:
source ~/.bashrc # or source ~/.zshrc
For automatic installation, download the run-in-shell-win-installer.ps1
file and run it in PowerShell by right-clicking the file (run as Administrator if necessary). If installation fails, follow the manual process described below.
-
Copy the script content and append it to your PowerShell
$PROFILE
. If you haven't previously created a profile, run the following command:New-Item -Path $PROFILE -Type File -Force
-
Then open it using:
notepad $PROFILE
-
Paste the script inside the file and save.
-
Reload your PowerShell session to apply changes.
-
If you encounter a permission error regarding script execution, run the following (as Administrator):
Set-ExecutionPolicy RemoteSigned
Or, to enable for current user only:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
-
Restart your terminal.
Thanks for the clarification! Here's the updated final section of your README.md
, now including instructions for setting up keyboard shortcuts via keybindings.json
as well:
To use these scripts via keyboard shortcuts inside Visual Studio Code:
-
Create a
.vscode
folder in the root of your project (if it doesn't already exist). -
Place the provided
tasks.json
file into the.vscode
folder. -
This file defines two tasks:
- Run with run → executes the file using
run
- Run with runf → executes the file using
runf
(usesinput.txt
and writes tooutput.txt
)
- Run with run → executes the file using
⚠️ Ensure that therun
andrunf
commands are globally available from your terminal before using them in VS Code.
By default you can use Ctrl + Shift + B
to use runf
(to compile and take input from input.txt
and show output to output.txt
). But if you want to bind the tasks to convenient keys like Ctrl + Shift + [
and Ctrl + Shift + ]
, you need to edit your keybindings.json
. Otherwise the run
command won't be avaialble to any keybindings.
-
Open VS Code.
-
Go to:
File → Preferences → Keyboard Shortcuts
-
Click the icon in the top-right corner that opens
keybindings.json
just on the left of split editor icon. -
Append the following entries to the array, making sure to add a comma
,
if there's already one or more entries:
{
"key": "ctrl+shift+[",
"command": "workbench.action.tasks.runTask",
"args": "Run with run"
},
{
"key": "ctrl+shift+]",
"command": "workbench.action.tasks.runTask",
"args": "Run with runf"
}
You can customize the keys to your liking.
tasks.json
only defines tasks, not their shortcuts — that's why you must editkeybindings.json
separately.
With this setup, you’ll be able to run your source code files using the run
and runf
commands via keyboard shortcuts directly from VS Code — no need to open a terminal manually.
To compile and execute a source file and see output in the shell:
run <filename>
Example:
run test.cpp
This supports .c
, .cpp
, .py
, .js
, .lua
, and .java
. You can modify the script to support more languages as needed.
To compile and execute a file with input from input.txt
and write output to output.txt
:
runf <filename>
Example:
runf test.cpp
Warning
Ensure input.txt
and output.txt
exist in the current directory, and the required compilers/interpreters are installed and available in your system's PATH
.
These scripts are especially handy for competitive programming or quick prototyping when paired with Vim or VS Code workflows.
Happy Coding 😛