-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstatus.sh
executable file
·94 lines (83 loc) · 1.94 KB
/
status.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
#!/bin/bash
#
# Quick status check of the working directory
#
# Author: Piero Grandesso
# https://github.com/piero-g/markdown-workflow
#
#####
# 0. events log and other checks
#####
# also: am I in the right place? (is there z-lib folder?)
if . ./z-lib/events-logger.sh ; then
echo "Starting events registration in $eventslog"
else
echo "Something went wrong with event logger, aborting! (is ./z-lib/ in its place?)"
exit 1
fi
# help
function printHelp() {
cat <<EOF
This script is to quickly check if the files in the working directory
have been updated. It will stamp a list of files for:
0-original/
1-layout/
2-publication/ [only the two most recent PDFs!]
It takes no arguments.
EOF
}
if [[ $# -eq 0 ]] ; then
# no given arguments (correct!)
printf '%b\n' "[$(date +"%Y-%m-%d %H:%M:%S")] status.sh started running, logging events" >> "$eventslog"
echo "Checking working directory status..."
else
printHelp
exit 0
fi
#####
# 1. print status on working directories
#####
# 0-original
echo -e "\n\n######\n"
if [ -d 0-original ]; then
if [[ $(ls -A 0-original) ]]; then
echo "content of 0-original:"
echo
# print list of files
ls -AgGht 0-original | cut -d ' ' -f 3-
else
echo "0-original is empty"
fi
else
echo "0-original not found"
fi
# 1-layout
echo -e "\n\n######\n"
if [ -d 1-layout ]; then
if [[ $(ls -A 1-layout) ]]; then
echo -e "content of 1-layout (media directories first):"
echo
# print list of directories
ls -AgGhtd 1-layout/*/ | cut -d ' ' -f 4-
# print list of MD files
ls -AgGht 1-layout/*.md | cut -d ' ' -f 3-
else
echo "1-layout is empty"
fi
else
echo "1-layout not found"
fi
# 2-publication
echo -e "\n\n######\n"
if [ -d 2-publication ]; then
if [[ $(ls -A 2-publication) ]]; then
echo "last two generated PDF:"
echo
# print only the two most recent PDF
ls -AgGht 2-publication/*.pdf | cut -d ' ' -f 3- | head -n 2
else
echo "2-publication is empty"
fi
else
echo "2-publication not found"
fi