summaryrefslogtreecommitdiff
path: root/fish/conf.d/worktime.fish
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-07 23:46:42 +0200
committerPaul Buetow <paul@buetow.org>2026-02-07 23:46:42 +0200
commitf408ae894e4e10bbf4358c7c07bb9618ef1353e4 (patch)
tree0722f09473a58f1b9027e271cd6bd0e96e7a390d /fish/conf.d/worktime.fish
parentbf56ef64278a90acab9116311e649e762d39cd34 (diff)
rename
Diffstat (limited to 'fish/conf.d/worktime.fish')
-rw-r--r--fish/conf.d/worktime.fish122
1 files changed, 122 insertions, 0 deletions
diff --git a/fish/conf.d/worktime.fish b/fish/conf.d/worktime.fish
new file mode 100644
index 0000000..2dfbe6b
--- /dev/null
+++ b/fish/conf.d/worktime.fish
@@ -0,0 +1,122 @@
+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::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 random_exercise "sort -R $WORKTIME_DIR/exercises.md | head -n 1"
+abbr -a random_exercises "sort -R $WORKTIME_DIR/exercises.md | head -n 10"
+abbr -a wl 'task add +work'
+abbr -a ql 'task add +personal'
+abbr -a pl 'task add +personal'