-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_take_note
More file actions
executable file
·60 lines (47 loc) · 1.06 KB
/
my_take_note
File metadata and controls
executable file
·60 lines (47 loc) · 1.06 KB
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
#!/bin/bash
# Simple note-taking script
# Alias => note
# Help message
case "$1" in
-h|--help)
echo "
${0##*/} [-h] (name)
-- script to track notes
where:
-h (--help) show this help text
"
exit 0 ;;
esac
# Generate a note ID
if type -fP uuidgen > /dev/null 2>&1; then
noteid=$(uuidgen)
else
# Basic fallback, if uuidgen isn't available.
printf -v noteid "%.10d\n" $RANDOM$RANDOM
fi
# Store the date using standard `date` format
#printf -v date "%(%a %e %b %X %Z %Y)T\n" -1
date=$(date)
# Store topic if given
if [ -z "$1" ]
then
topic="notes"
else
topic="$1"
fi
# Filename to write to
filename="$topic.txt"
# Path to send file
path="$HOME/Desktop/scripts/notes/$filename"
# Ask the user for input, reference => help read
read -e -p "Add note: " note
# Note template
echo "_______________________________________________________
Note ID: $noteid
Author: $USER ($UID)
Date: $date
Host: ${HOSTNAME:-`hostname`}
Note: $note
" >> "$path" # Good practice to wrap variables with double quotes
# Message to user
echo "Note '$note' saved to: $path"