Simple implementation in bash for compiling some supported code files and executing them for you.

Simple implementation in bash for compiling some supported code files and executing them for you.

Contributors Forks Stargazers Issues MIT License LinkedIn

code-runner

run supported lang files with single command
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Integrating with vscode
  5. Integrating with vim
  6. Contributing
  7. Change.log
  8. License
  9. Contact
  10. Acknowledgments

About The Project

This is a script written in bash, which compiles the code file and run it for you and delete other junk files if created during the process of compilation, all this with one command.

(back to top)

Built With

This project is made with following langs/frameworks.

  • BASH

(back to top)

Getting Started

Installation

Now since we are done with the setting up of environment suitable for the project to compile/run, let's install and configure the project on your system locally now.

  1. Clone the repo.
  2. Make the setup script executable.
  3. Execute the setup script.

Copy the following commands to perform above mentioned tasks!

git clone https://github.com/proffapt/code-runner.git
cd code-runner
chmod +x setup.sh
./setup.sh
  1. Run the code
    run my_code.c
    OR
    run ~/path/to/my_code.c

(back to top)

Usage

Integrating with vscode

Create custom keybindings for vscode to use this script more conveniently in vscode, you can copy my keybindings from vscode-keybindings into your keybindings.json

  • alt+space

    • If there is no instance of terminal: Spawns a new terminal > shifts the focus to it.
    • If the instance already exists and focus is on editor pane: Focuses the terminal.
    • If the focus is on terminal: Focuses the editor pane keeping the terminal at it's place.
  • cmd+contextmenu -- use twice for execution

    • If there is no terminal instance: Spawns a new terminal > shifts focus to it(DOESN"T EXECUTE THE CODE, press again to execute the code).
    • If instance exists and focus is on editor pane: Shifts focus to terminal(DOESN"T EXECUTE THE CODE, press again to execute the code).
    • If the focus is on terminal: Executes the code.

    ^ NOTE: Code execution is also possible even if the code file is not directly inside the folder opened in vscode.

Stores previous execution history, as there is no new terminal created everytime, it's created only when not present else uses the same terminal

(back to top)

Integrating with vim

I made a custom keybinding to work with my code-runner on vim, add the lines from vim-keybindings to your vim configuration file

  • rr

    • In NORMAL mode: Saves the file > creates a new floaterm buffer > shifts focus to it > runs the code(CLOSE the buffer with any key after completion of execution).

Doesn't store previous execution history, as there is a new buffer created everytime

  • ff

    • In NORMAL mode with no existing floaterm buffer: Saves the file > creates a new floaterm buffer > shifts focus to it > runs the code.
    • In NORMAL mode with existing floaterm buffer but focus on code buffer: Saves the file > shifts focus to floaterm buffer > runs the code.
    • In NORMAL mode with existing floaterm buffer and focus on flaoterm buffer: Hides the floaterm buffer > focuses on the working file's buffer.
    • In TERMINAL mode: Hides active floaterm buffer > focuses on the working file's buffer.

Stores previous execution history, as there is no new buffer created everytime, it's created only when not present else uses the same buffer

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Changelog

v1.1.5

Added or Changed

  • Added basic support for go-lang.

(back to top)

License

Distributed under the BSD-2-Clause License. See LICENSE.txt for more information.

(back to top)

Contact

Arpit Bhardwaj - Twitter - Telegram - [email protected]

Company website: Cybernity - CybernityForum

Project Link: https://github.com/proffapt/code-runner

(back to top)

Acknowledgments

(back to top)

Download Source Code

Download ZIP
Jul 10, 2022