blob: 9c936ea121390a43d4341a95ccbdcd277723ac13 (
plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
set -gx WORKTIME_DIR ~/git/worktime
if test (uname) = Darwin -a ! -f ~/.wtloggedin
echo "Warn: Not logged in, run wtlogin"
end
function worktime
ruby $WORKTIME_DIR/worktime.rb $argv
end
function worktime::sync
cd $WORKTIME_DIR
git commit -a -m sync
git pull
git push
cd -
end
function worktime::supersync_sync
if not test -d $WORKTIME_DIR
echo "Warning: Directory $WORKTIME_DIR does not exist"
return 1
end
cd $WORKTIME_DIR
if test (count $argv) -gt 0 -a $argv[1] = sync_quotes
if test -d ~/Notes/HabitsAndQuotes
echo "" >work-wisdoms.md.tmp
for notes in ~/Notes/random/{Productivity,Mentoring}.md
grep '^\* ' $notes >>work-wisdoms.md.tmp
end
sort -u work-wisdoms.md.tmp >work-wisdoms.md
rm work-wisdoms.md.tmp
git add work-wisdoms.md
grep '^\* ' ~/Notes/random/Exercise.md >exercises.md
git add exercises.md
end
end
find . -name '*.txt' -exec git add {} \;
find . -name '*.json' -exec git add {} \;
find . -name '*.csv' -exec git add {} \;
git commit -a -m sync
git pull origin master
git push origin master
cd -
end
# uprecords collect/import helpers live in the (private) worktime repo so that
# host-specific details stay out of the public dotfiles repo. The functions
# guard internally (collect on Darwin, import on earth).
if test -f $WORKTIME_DIR/scripts/uprecords-sync.fish
source $WORKTIME_DIR/scripts/uprecords-sync.fish
end
function worktime::supersync
worktime::supersync_sync sync_quotes
taskwarrior::invoke
if functions -q worktime::uprecords::darwin::collect
worktime::uprecords::darwin::collect
worktime::uprecords::darwin::import
end
worktime::supersync_sync no_sync_quotes
end
function worktime::wisdom_reminder
if test -f $WORKTIME_DIR/work-wisdoms.md
sed -n '/^\* / { s/\* //; p; }' $WORKTIME_DIR/work-wisdoms.md | sort -R | head -n 1
end
end
function worktime::report
if test -f ~/.wtloggedin
if test -f ~/.wtmaster
worktime --report | tee $WORKTIME_DIR/report.txt
else
worktime --report
end
worktime::wisdom_reminder
end
end
function worktime::add
set -l seconds $argv[1]
set -l what $argv[2]
set -l descr $argv[3]
set -l epoch (date +%s)
if test -z "$what"
set what work
end
if test -z "$descr"
worktime --add $seconds --epoch $epoch --what $what
else
worktime --add $seconds --epoch $epoch --what $what --descr "$descr"
end
worktime::report
end
function worktime::log
set -l seconds $argv[1]
set -l what $argv[2]
set -l epoch (date +%s)
if test -z "$what"
set what work
end
worktime --log --epoch $epoch --what $what
worktime::report
end
function worktime::login
set -l what $argv[1]
if test -z "$what"
set what work
end
touch ~/.wtloggedin
worktime --login --what $what
worktime::wisdom_reminder
end
function worktime::logout
set -l what $argv[1]
if test -z "$what"
set what work
end
if test -f ~/.wtloggedin
rm ~/.wtloggedin
end
worktime --logout --what $what
worktime::report
end
function worktime::status
worktime::report
if test -f ~/.wtloggedin
echo "You are logged in"
set -l num_worklog (ls $WORKTIME_DIR | grep wl- | wc -l)
if test $num_worklog -gt 0
echo "$num_worklog entries in the worklog in $WORKTIME_DIR/wl-*"
end
else
echo "You are not logged in"
end
end
abbr -a cdworktime "cd $WORKTIME_DIR"
abbr -a wt worktime
abbr -a wtedit 'worktime --edit'
abbr -a wtreport 'worktime --report'
abbr -a wtadd 'worktime::add'
abbr -a wtlog 'worktime::log'
abbr -a wtlogin 'worktime::login'
abbr -a wtlogout 'worktime::logout'
abbr -a wtstatus 'worktime::status'
abbr -a wtsync 'worktime::sync'
abbr -a wtf 'worktime --report'
abbr -a wl 'task add +work'
abbr -a ql 'task add +personal'
abbr -a pl 'task add +personal'
|