-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog-day.zsh
executable file
·53 lines (41 loc) · 927 Bytes
/
log-day.zsh
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
#!/bin/zsh
## Get day number
tail README.md
echo "What number day is it?"
read dayNumber
re='^[0-9]+$'
if ! [[ $dayNumber =~ $re ]];
then
echo "error: You did not enter an integer."
exit 1
fi
## Add to README
currentDate=$(date +"%B %d, %Y")
MESSAGE_FILE_NAME=".tmp_dialy_message_file.txt"
rm $MESSAGE_FILE_NAME
vim $MESSAGE_FILE_NAME
readmeMessage="
**Day $dayNumber - $currentDate:**
$(cat $MESSAGE_FILE_NAME | sed 's/\. */.\
/g')"
echo $readmeMessage
echo $readmeMessage >> README.md
## Git Commit
commitMessage="$dayNumber of 100 Days of Swift (II)
$(cat $MESSAGE_FILE_NAME | fold -w 80 -s)"
rm $MESSAGE_FILE_NAME
echo "\n---\nHere is todays commit message:"
echo $commitMessage
echo "\n"
echo "Shall I commit to git? (y/n)"
read shouldCommit
if [[ $shouldCommit == 'y' ]]
then
echo "Comitting to git repo..."
git add --all
git commit -m $commitMessage
git push
else
echo "Nothing commited."
fi
exit