-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadme
executable file
·42 lines (34 loc) · 878 Bytes
/
readme
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
#!/bin/bash
HISTORY="$HOME/.bash_eternal_history"
NOTNEWETRY=
DATE=$(date "+%m/%d/%y %k:%M:%S")
LASTDATE=$(tail -n 1 README | cut -f 1)
LASTCOMMAND=$(tail $HISTORY | tail -n 1)
#echo $LASTCOMMAND
#($(eval $LASTCOMMAND))
PWD=$(pwd)
COMMENT=$1
OPTIONS="n:"
NUMARGS=$#
if [ $NUMARGS -eq 1 ]; then
echo -e "$DATE\t$PWD\t$COMMENT" >> README
echo -e "$DATE\t$PWD\t$COMMENT" >> ~/notebook.txt
fi
if [ $NUMARGS -eq 0 ]; then
echo -e "$LASTDATE\t$PWD\t$LASTCOMMAND" >> README
echo -e "$LASTDATE\t$PWD\t$LASTCOMMAND" >> ~/notebook.txt
while read line
do
echo -e "$LASTDATE\t$PWD\t$line" >> README
echo -e "$LASTDATE\t$PWD\t$line" >> ~/notebook.txt
done < "${1:-/dev/stdin}"
fi
while getopts $OPTIONS option
do
case $option in
n)
NOTNEWENTRY=$OPTARG
echo -e "$LASTDATE\t$PWD\t$NOTNEWENTRY" >> README
;;
esac
done