├── remove.sh ├── initialize.sh ├── help.txt ├── README.md └── autotemp /remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Everything related to autotemp is removed 3 | 4 | sudo rm /bin/autotemp 5 | sudo rm -r "$HOME/.config/Autotemp/" 6 | 7 | echo "OK!" 8 | -------------------------------------------------------------------------------- /initialize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #This is the initial file which should be executed so that the base folder for 3 | #storing templates is created 4 | if [[ -d "$HOME/.config/Autotemp/templates" ]] 5 | then 6 | echo "$HOME/.config/Autotemp/templates already exist's" 7 | else 8 | mkdir -p $HOME/.config/Autotemp/templates 9 | fi 10 | 11 | chmod +x initialize.sh 12 | chmod +x autotemp 13 | chmod +x remove.sh 14 | 15 | sudo cp autotemp /bin/ 16 | sudo cp help.txt "$HOME/.config/Autotemp/" 17 | echo "This is a small project to create and manage templates made by Prathamesh and Sahil" 18 | echo "Script Loaded" 19 | autotemp --help -------------------------------------------------------------------------------- /help.txt: -------------------------------------------------------------------------------- 1 | NAME: 2 | autotemp - Manages templates made by user to be used before starting any project. 3 | 4 | 5 | SYNOPSIS: 6 | autotemp [OPTION]... [FILE]... 7 | 8 | DESCRIPTION 9 | Creates and Manages templates which can be used while starting a project\ 10 | 11 | $ autotemp TemplateName file1 file2 file3 ... 12 | To add template content to given files 13 | 14 | 15 | --add, 16 | Adds a template which can be used later 17 | Usage: autotemp --add TemplateName 18 | 19 | -p, 20 | copies the content of the template to a file with given specific path 21 | Usage: autotemp -p TemplateName Path_to_file 22 | 23 | -e, 24 | Opens the given template in vim editor 25 | Usage: autotemp -e TemplateName 26 | 27 | -l, 28 | Lists out all template stored 29 | Usage: autotemp -l 30 | 31 | -pf, 32 | Displays content of the given template 33 | Usage: autotemp -pf TemplateName 34 | 35 | -r, 36 | Removes the given template from the stored templates 37 | Usage: autotemp -r TemplateName 38 | 39 | --help, 40 | Displays how to use the commands and other usages 41 | Usage: autotemp --help (or) autotemp --h 42 | 43 | AUTHOR 44 | Written by Prathamesh Desai and Sahil. 45 | 46 | REPORTING BUGS 47 | Contact : "crois.en.toi180321@gmail.com". 48 | 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Template Automater 2 | Simple CLI utility to create and manage templates which can be applied to multiple files at once. 3 | 4 | 5 | ## Installation 6 | 7 | Use the package manager to install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) first, then execute the following commands in your desired directory. 8 | 9 | ```bash 10 | git clone "https://github.com/Crois-En-Toi/Template-Automater.git" 11 | cd Template-Automater 12 | ./initialize.sh 13 | ``` 14 | 15 | ## Usage 16 | Adding an editable template using --add 17 | ```bash 18 | autotemp --add TemplateName 19 | ``` 20 | 21 | Copying content of template to a file in certain path using -p 22 | ```bash 23 | autotemp -p TemplateName PathToFile 24 | ``` 25 | 26 | Editing a template in Vim editor using -e 27 | ```bash 28 | autotemp -e TemplateName 29 | ``` 30 | 31 | Listing all templates using -l 32 | ```bash 33 | autotemp -l 34 | ``` 35 | 36 | Display content of a template using -pf 37 | ```bash 38 | autotemp -pf TemplateName 39 | ``` 40 | 41 | Removing a template using -r 42 | ```bash 43 | autotemp -r TemplateName 44 | ``` 45 | 46 | 47 | 48 | Creating multiple files with a template as preset (or appending template content to multiple files). 49 | ```bash 50 | autotemp TemplateName file1 file2 file3 51 | ``` 52 | 53 | Displaying all available commands on the terminal using --help 54 | ```bash 55 | autotemp --help (or) autotemp --h 56 | ``` 57 | 58 | ## Contributing 59 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 60 | 61 | ## License 62 | [MIT](https://choosealicense.com/licenses/mit/) 63 | 64 | ## Author 65 | Written by [Prathmesh](https://github.com/ozer619) and [Sahil](https://github.com/Sahil-101). 66 | 67 | Readme by [Suryansh](https://github.com/Hit360D). 68 | 69 | ## Support 70 | Report bugs by emailing at crois.en.toi180321@gmail.com 71 | -------------------------------------------------------------------------------- /autotemp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #This file consist's of the main script to run the tool 3 | 4 | # for adding the given template 5 | if [[ $1 == "--add" ]] 6 | then 7 | if [[ -d "$HOME/.config/Autotemp/templates" ]] 8 | then 9 | touch "$HOME/.config/Autotemp/templates/$2.txt" 10 | echo "Enter the contents of template" 11 | cat > "$HOME/.config/Autotemp/templates/$2.txt" 12 | printf "\n" 13 | echo "==================================================" 14 | echo "Template $2 succesfully created the contents are:" 15 | echo "==================================================" 16 | printf "\n" 17 | cat "$HOME/.config/Autotemp/templates/$2.txt" 18 | fi 19 | 20 | # list out all existing templates 21 | elif [[ $1 == "-l" ]] 22 | then 23 | ls "$HOME/.config/Autotemp/templates/" 24 | 25 | # printf all the content in the given template 26 | elif [[ $1 == "-pf" ]] 27 | then 28 | more "$HOME/.config/Autotemp/templates/$2.txt" 29 | 30 | # gives specific path to where the template is to be written over (file must already exist) 31 | elif [[ $1 == "-p" ]] 32 | then 33 | cat "$HOME/.config/Autotemp/templates/$2.txt" >> "$3" 34 | 35 | # for editing the template file 36 | elif [[ $1 == "-e" ]] 37 | then 38 | echo "Opening $2 file in vim, do edit as required" 39 | vim "$HOME/.config/Autotemp/templates/$2.txt" 40 | 41 | # for removing a template file 42 | elif [[ $1 == "-r" ]] 43 | then 44 | echo "Removing File $2 from the template store" 45 | rm "$HOME/.config/Autotemp/templates/$2.txt" 46 | 47 | # help function to tell more about the command usage 48 | elif [[ $1 == "--help" || $1 == "--h" ]] 49 | then 50 | more "$HOME/.config/Autotemp/help.txt" 51 | else 52 | if [[ $# -eq 1 ]] 53 | then 54 | echo "invalid input use autotemp --help for help" 55 | else 56 | if [[ -f "$HOME/.config/Autotemp/templates/$1.txt" ]] 57 | then 58 | 59 | cat "$HOME/.config/Autotemp/templates/$1.txt" | tee -a "${@:2}" > "/dev/null" 60 | 61 | else 62 | echo "provided template doesnot exist create one using --add " 63 | fi 64 | fi 65 | fi 66 | --------------------------------------------------------------------------------