From ef53c92c4fa20b17ffa2fe24bf74070bcca638dc Mon Sep 17 00:00:00 2001 From: rinri Date: Tue, 2 Feb 2021 17:35:19 +0000 Subject: [PATCH] Added new features and fixed bugs: + added Makefile functionality to not compile a file if it haven't changed + you don't have to enter extension of the file in both create.sh and run.sh. You also can enter a filename with extension(works only with .cpp files) + fixed color.sh bug not printing the last line --- Makefile | 10 ++++++++++ README.md | 7 ++++--- setup.sh | 18 ++++++++++++------ 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b3ee6f1 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +CXX = g++ +CXXFLAGS = -Wall -Werror -std=c++14 + +all: $(patsubst %.cpp, %.out, $(wildcard *.cpp)) + +%.out: %.cpp Makefile + $(CXX) $(CXXFLAGS) $< -o $@ + +clean: + rm *.out \ No newline at end of file diff --git a/README.md b/README.md index 94c814a..fb4b666 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,16 @@ First, you have to write template which will be used to create new files. Rememb # Using -In order to create a new .cpp file, you have to run create.sh with filename argument without an extension: +In order to create a new .cpp file, you have to run create.sh with filename argument: ```shell ./create.sh 1234a ``` -You will be automatically redirected to neovim. +It will create 1234a.cpp. You can enter 1234a.cpp instead of 1234a and you will get the same result. +Then you will be automatically redirected to neovim. -To compile&run file, you can just use run.sh with filename(this time with extension): +To compile and run file, you can use run.sh with filename as an argument(you can use both filename with extension and without): ```shell ./run.sh 1234a.cpp diff --git a/setup.sh b/setup.sh index 5cc9462..96350b1 100755 --- a/setup.sh +++ b/setup.sh @@ -1,22 +1,28 @@ +mkdir .config.d + # create.sh -echo $'cp template.cpp $1.cpp\nnvim -s .gg $1.cpp' > create.sh +echo $'cp .config.d/template.cpp ${1%.*}.cpp\nnvim -s .config.d/cursorpos ${1%.*}.cpp' > create.sh # template read -n 1 -r -s -p $'Press any key to create template file...\n' -nvim template.cpp +nvim .config.d/template.cpp # start line read -p $'Enter starting line of cursor:\n' line ((line=line-1)) -echo "$line"gg > .gg +echo "$line"gg > .config.d/cursorpos # color.sh -echo $'echo -en "\033[31m" ## red\neval $* | while read line; do\necho -en "\033[36m" ## blue\necho $line\necho -en "\033[31m" ## red\ndone\necho -en "\033[0m" ## reset color' > color.sh +echo $'echo -en "\033[31m" ## red\neval $* | while read line; do\necho -en "\033[36m" ## blue\necho $line\necho -en "\033[31m" ## red\ndone\necho -en "\033[0m" ## reset color' > .config.d/color.sh # run.sh -echo $'g++ -std=c++14 -g $1\necho "Compiled..."\n./color.sh ./a.out\necho' > run.sh +echo $'make\necho "Compiled..."\n./.config.d/color.sh .config.d/.nl ./"${1%.*}.out"\necho' > run.sh + +# .nl +echo $'./$1\necho' > .config.d/.nl # make all executable chmod +x create.sh chmod +x run.sh -chmod +x color.sh +chmod +x .config.d/color.sh +chmod +x .config.d/.nl