newcpp is a minimalist command-line tool for quickly generating .cpp files based on a predefined template. Perfect for competitive programmers, students, and anyone who wants to save time creating C++ source files.
- 📝 Create new
.cppfile from a template (e.g.SAMPLE.cpp) - 🔁 Automatically replaces template placeholders (like filenames inside comments or compile commands)
- 🪄 Instantly opens the file in VS Code
- 🧃 Lightweight, terminal-friendly, and fast
- Clone this repo:
git clone https://github.com/nghtudung/newcpp.git- Make the script executable:
chmod +x /path/to/newcpp/newcpp.py- Add an alias to your shell config:
# If you're using zsh:
echo 'alias newcpp="/path/to/newcpp/newcpp"' >> ~/.zshrc
# Or for bash:
echo 'alias newcpp="/path/to/newcpp/newcpp"' >> ~/.bash_profile- Reload your shell:
source ~/.zshrc
# or
source ~/.bash_profilenewcpp hello.cpp➡ This will:
- Copy everything from
SAMPLE.cpp - Replace all internal occurrences of
"SAMPLE.cpp"with"hello.cpp" - Open
hello.cppin VS Code
📁 ~/.../newcpp/
├── newcpp.py # <- The Python script
└── SAMPLE.cpp # <- Your template file
- Put your own favourite template inside
SAMPLE.cpp - Works on macOS (I haven't test on Linux or Windows)
// g++ SAMPLE.cpp -o SAMPLE && ./SAMPLE
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
// Your code here
return 0;
}From GieJack™ with love ❤️ Why don't you star this repo?