diff --git a/.config.d/.nl b/.config.d/.nl index cea768b..e54ebaa 100755 --- a/.config.d/.nl +++ b/.config.d/.nl @@ -1,2 +1,4 @@ +#!/bin/sh + ./$1 echo diff --git a/.config.d/color.sh b/.config.d/color.sh index a6b08ed..17ac0a2 100755 --- a/.config.d/color.sh +++ b/.config.d/color.sh @@ -1,7 +1,9 @@ -echo -en "" ## red +#!/bin/sh + +echo -n "" ## red eval $* | while read line; do -echo -en "" ## blue +echo -n "" ## blue echo $line -echo -en "" ## red +echo -n "" ## red done -echo -en "" ## reset color +echo -n "" ## reset color diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bc0e89 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.cpp +*.out +*.h +*.hpp +bits +./.config.d/*.cpp +./.config.d/cursorpos \ No newline at end of file diff --git a/Makefile b/Makefile index 9da09ef..7b82188 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,10 @@ all: $(patsubst %.cpp, %.out, $(wildcard *.cpp)) %.out: %.cpp Makefile $(CXX) $(CXXFLAGS) $< -o $@ +cpstd: + mkdir bits + cp /usr/include/c++/*/*/bits/stdc++.h bits + $(CXX) $(CXXFLAGS) bits/stdc++.h + clean: rm *.out \ No newline at end of file diff --git a/README.md b/README.md index a698592..402534e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +Cpsrc is a tool to automate and enhance competitive programmer's experience. It works well with neovim and C++. You can also modify it to use the editor and programming language of your choice. + +Cpsrc offers several features: +- Automatic template +- Fast and easy compilation (using Makefile and precompiled headers) +- Colored input/output + # Installation Clone the repository and make setup.sh executable and run it: @@ -9,37 +16,31 @@ chmod +x setup.sh ./setup.sh ``` -First, write a template which will be used to create new files. Enter the number of the starting line. That is it! +Write a template that will be used to create new .cpp files. Enter the number of the starting line. # Usage -To create a new .cpp file, run create.sh with filename argument: +To create a new .cpp file, run create.sh with a filename as an argument: ```shell ./create.sh 1234a ``` -It will create 1234a.cpp and open neovim. Enter either type 1234a.cpp and 1234a. +It will create 1234a.cpp and open neovim. Enter either 1234a.cpp or 1234a. -To compile and run file, use run.sh with filename(or problem name) as an argument: +To compile and run the file, use run.sh with the filename (or problem name, e.g., 1234a) as an argument: ```shell ./run.sh 1234a.cpp ``` -To compile faster, precompile needed header files in the directory. +To compile extremely fast, precompile needed header files in the directory. To precompile bits/stdc++.h use `make`: ```shell -# copy libraries -mkdir bits -cd bits -cp /usr/include/c++/10.2.0/x86_64-pc-linux-gnu/bits/stdc++.h . - -# compile them and use the same c++ standard as in Makefile -g++ -g -std=c++14 stdc++.h +make cpstd ``` -Don't forget to use double quotes in the template. GCC uses the local precompiled library first. If there is no local library, it uses system's one. +If it didn't work, you should do it manually by copying a header file in the directory and compiling it with the same flags used in the Makefile. Don't forget to use double quotes in your template. With double quotes, GCC uses a local header first. ```c++ #include "bits/stdc++.h" diff --git a/create.sh b/create.sh index dcf1c38..6a93df4 100755 --- a/create.sh +++ b/create.sh @@ -1,2 +1,4 @@ +#!/bin/sh + cp .config.d/template.cpp ${1%.*}.cpp nvim -s .config.d/cursorpos ${1%.*}.cpp diff --git a/run.sh b/run.sh index 1a7978f..84d268d 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,5 @@ +#!/bin/sh + make echo "Compiled..." ./.config.d/color.sh .config.d/.nl ./"${1%.*}.out" diff --git a/setup.sh b/setup.sh index 81b7f05..01bbc82 100755 --- a/setup.sh +++ b/setup.sh @@ -1,13 +1,14 @@ +#!/bin/sh + # template -read -n 1 -r -s -p $'Press any key to create template file...\n' +read -p 'Press Enter to create a template...' line nvim .config.d/template.cpp -# start line -read -p $'Enter starting line of cursor:\n' line -((line=line-1)) +# starting line +read -p "Enter the starting line: " line echo "$line"gg > .config.d/cursorpos -# make all executable +# make everything executable chmod +x create.sh chmod +x run.sh chmod +x .config.d/color.sh