diff --git a/plugins/Cmaker/Cmaker.plugin.zsh b/plugins/Cmaker/Cmaker.plugin.zsh new file mode 100644 index 000000000..f2c73391d --- /dev/null +++ b/plugins/Cmaker/Cmaker.plugin.zsh @@ -0,0 +1,49 @@ +alias cjump="nvim $(mdfind -onlyin . -name 'main' | grep -A 1 /Users)" + +alias clist="mdfind -onlyin . -interpret .cpp & mdfind -onlyin . -interpret .cc" + +function cgen(){ + mkdir $1 + cd $1 + touch CMakeLists.txt + cat ~/.oh-my-zsh/custom/plugins/cMaker/ListTemplate.txt >> CMakeLists.txt + mkdir src + cd src + touch main.cpp + cd ../.. +} + +function crun(){ + #VAR=${1:-.} + cd $1 + cmake . + cmake --build . +} + +function cbin(){ + cbuild CPP + cat $1 >> CPP/src/main.cpp + crun CPP + mv cpc ../ + cd .. + rm -r CPP +} + +function cput(){ + mv $1/*(DN) $2/ +} + +function ccomp(){ + cbuild qwertyu + cd qwertyu/src + rm main.cpp + cd ../.. + mv $1/*(DN) qwertyu/src/ + crun qwertyu + mv cpc ../ + rm -r qwertyu +} + +function ctemp(){ + open ~/.oh-my-zsh/custom/plugins/cMaker/ListTemplate.txt +} diff --git a/plugins/Cmaker/ListTemplate.txt b/plugins/Cmaker/ListTemplate.txt new file mode 100644 index 000000000..ae646f2b5 --- /dev/null +++ b/plugins/Cmaker/ListTemplate.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(wat) +cmake_minimum_required(VERSION 3.15) +add_executable(cpc /Users/aadipalnitkar/c++/wat/src/main.cpp) +#find_package() +#target_incldue_directories() +#target_link_directories() +#target_link_libraries() diff --git a/plugins/Cmaker/README.md b/plugins/Cmaker/README.md new file mode 100644 index 000000000..9ebe97a4a --- /dev/null +++ b/plugins/Cmaker/README.md @@ -0,0 +1,23 @@ +# Cmaker +An oh-my-zsh plugin to make using cmake easier. + +## How It Works +Cmaker uses a template text file located in the ```~/.oh-my-zsh/custom/plugins/cMaker``` directory to create a CMakeLists.txt file which will act as a config file when commands like ```cgen```,```ccomp``` and ```cbin``` are run. You can use ```ctemp``` to edit the template file or you can use ```cgen``` and then edit the CMakeLists.txt file after it has been generated. However, this not possible with commands like ```ccomp``` and ```cbin``` as they instantly run the code after generating the cmake files. In that case, you mest edit the template. A basic template has already been setup for you. + +## Commands +* ```cjump``` -> If you are in the directory of your project ```cjump``` will open the 'main' file in your project. No arguements for this commands +* ```clist``` -> ```clist``` will list every file ending with .cpp or .cc in your current directory. No arguements for this commands +* ```cgen``` -> Creates the ```CMakeLists.txt``` file (with basic configs allowing you to run instantly) as well as the src directory along with main.cpp in the src. Usage : ```cgen `` +* ```crun``` -> This will produce a binary file after you have used ```cgen``` and written in the main.cpp file. Use ```crun ``` +* ```cbin``` -> This will instantly create a binary file called cpc. Pass filename as an arguement : ```cbin ``` +* ```cput``` -> Moves all files from one directory to another. Usage : ```cput ``` +* ```ccomp``` -> Runs a directory of cpp files containing main.cpp and which are part of one project. Usage : ```ccomp ``` +* ```ctemp``` -> Allows you to edit the template with which CMakeLists.txt will be created. No arguements required + +## Notes: +* cbuild | Make sure your project name doesnt conflict with other directory names. +* cbin | This only works with single files but is faster than ccomp. +* ccomp | Make sure that you don't have a directory called qwertyu in your current dir when you're running this. +* This plugin can only be used to generate templates for binary projects not library projects. + +***Created by Aadi P***