-
Notifications
You must be signed in to change notification settings - Fork 1
/
new
executable file
·68 lines (61 loc) · 1.17 KB
/
new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
helptext() {
echo "new: Incorrect usage"
echo "Use flags to specify the type of file"
echo "Available Flags"
echo "==============="
echo " --c: A new C template"
echo " --cpp: A new CPP template"
echo " --java: A new Java template"
echo " --bash: A new Bash template"
echo " --python: A new Python template"
echo " --texreport: A new LaTeX Report template"
echo " --texarticle: A new LaTeX Article template"
echo " --comp: A new Competitive Coding template in C++"
}
createFile() {
case $1 in
--java )
cp ~/Templates/java ./$2.java
;;
--c )
cp ~/Templates/c ./$2.c
;;
--cpp )
cp ~/Templates/cpp ./$2.cpp
;;
--comp )
cp ~/Templates/comp ./$2.cpp
;;
--python )
cp ~/Templates/python ./$2.py
;;
--bash )
cp ~/Templates/bash ./$2.sh
chmod +x ./$2.sh
;;
--texreport )
cp ~/Templates/texreport ./$2.tex
;;
--texarticle )
cp ~/Templates/texarticle ./$2.tex
;;
* )
helptext
;;
esac
}
NAME="new"
if [[ $# -eq 3 ]]; then
if [[ $1 == "-o" ]]; then
createFile $3 $2
elif [[ $2 == "-o" ]]; then
createFile $1 $3
else
helptext
fi
elif [[ $# -eq 1 ]]; then
createFile $1 "new"
else
helptext
fi