-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakenote
More file actions
executable file
·34 lines (28 loc) · 833 Bytes
/
makenote
File metadata and controls
executable file
·34 lines (28 loc) · 833 Bytes
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
#!/bin/sh
# Creates a note file with boilerplate code inside.
# Note: This script assumes you have a NOTES_HOME variable that points to the
# root directory of your notes.
# Check if $NOTES_HOME variable is set
if [[ -z ${NOTES_HOME+x} ]]; then
echo 'No NOTES_HOME environment variable found!'
exit 1
fi
# Check if filename is supplied
if [[ -z ${1+x} ]]; then
echo 'No filename provided!'
echo 'Usage: makenote <filename>'
exit 1
fi
# Check to make sure existing file is not changed
if [[ -e $1 ]]; then
echo "$1 already exists!"
exit 1
fi
function pathToNotesHome {
for (( i=1; i<=$(depth $NOTES_HOME `pwd`); i++ ));
do echo -n ../;
done
}
echo "<link rel='stylesheet' href='$(pathToNotesHome)shared/style.css'>" >> $1
echo >> $1
echo "<a href='$(pathToNotesHome)index.html'>Return to homepage.</a>" >> $1