-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbliss.sh
196 lines (118 loc) · 4.68 KB
/
bliss.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# a bliss shell command for easy, uploading, posting, and project sharing...
# put this in your .zshrc for easy bliss blogging, see the readme.md for instructions!
# it's easy!
function bliss() {
if [ ! -z $1 ]; #if argument 1 exists...
then
# get the date...
this_date=$(date +"%Y-%m-%d")
this_year=$(date +"%Y")
this_month=$(date +"%b")
the_second=$(date +"%S")
talk_link="./_posts/${this_year}"
project_link="./_projects/${this_year}"
# 1. make the talk post...need title and tag
if [ $1 = "talk" ];
then
if [ ! -d "${talk_link}" ]; then
#if there's no year directory
mkdir ${talk_link}
fi
if [ ! -z $2 ]; #the filename is there...
then
if [ ! -z $3 ]; #the title is there...
then
if [ ! -z $4 ]; #the tag is there...
then
if [ -e ./tag/$4.md ];
then
sed "s/Talk title/$3/;s/talk date/${this_date}/;s/talk_tag/$4/" ./_templates/talks.md > ${talk_link}/${this_date}-$2.md
echo "new talk made! tag is included..."
else
# makes the tag name uppercase
upper_4=${(U)${4}:0:1}${${4}#?}
# makes the tag file, since new
sed "s/Tag Title/${upper_4} Talks/;s/tag name/$4/" ./_templates/tag_template.md > ./tag/$4.md
sed "s/Talk title/$3/;s/talk date/${this_date}/;s/talk_tag/$4/" ./_templates/talks.md > ${talk_link}/${this_date}-$2.md
echo "new talk made! tag is included..."
fi
else
sed "s/Talk title/$3/;s/talk date/${this_date}/;" ./_templates/talks.md > ./somefile.md
sed '5d' ./somefile.md > ${talk_link}/${this_date}-$2.md
rm ./somefile.md
echo "new talk made! no tags.."
fi
else
sed "s/talk date/${this_date}/" ./_templates/talks.md > ${talk_link}/${this_date}-$2.md
echo "new talk made! you set the title..."
fi
else
sed "s/talk date/${this_date}/" ./_templates/talks.md > ${talk_link}/${this_date}-new-talk${the_second}.md
echo "new talk made! you set the filename..."
fi
else
if [ $1 = "project" ]; #if need a project
then
if [ ! -d "${project_link}" ]; then
#if there's no year directory
mkdir ${project_link}
fi
if [ ! -z $2 ]; #the filename is there...
then
if [ ! -z $3 ]; #the title is there...
then
sed "s/Proj Title/$3/;s/proj date/${this_date}/" ./_templates/projects.md > ${project_link}/$2.md
echo "new project made! you set keywords and summary..."
else
sed "s/proj date/${this_date}/" ./_templates/projects.md > ${project_link}/$2.md
echo "new project made! you set title, keywords, and summary..."
fi
else
sed "s/proj date/${this_date}/" ./_templates/projects.md > ${project_link}/plain_project${the_second}.md
echo "new project made! a plain template!"
fi
else
#the uploads...
if [ $1 = "upload" ];
then
upload_links=("others" "papers" "extras" "books" "articles")
upload_base="./professional_files"
is_inside="false"
#files exist
if [ ! -z $2 ]; #folders exist
then
if [ ! -z $3 ]; #files entered...
then
# loop through the various folders...
if [ ! -d ${3} ] && [ ! -f ${3} ];
then
echo "need valid directory or file path...typo?"
else
for i in "${upload_links[@]}" #note: the '#' shows no. of elements
do
if [ $2 = $i ]; then
cp -R $3 ${upload_base}/${i}
echo "uploaded the file! check ./professional_files/${i} for the file..."
is_inside="true"
fi
done
if [ ${is_inside} = "false" ];
then
echo "can't upload to that location! use the names in the ./professional_files folder..."
fi
fi
else
echo "need which files in ./professional_files/${2} you want uploaded..."
fi
else
echo "need which folder in ./professional_files you want uploaded..."
fi
else
echo "can't bliss that, try upload, talk, or project..."
fi
fi
fi
else
echo "need either talk, upload, or project..."
fi
}