summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-02 18:00:35 +0300
committerPaul Buetow <paul@buetow.org>2026-05-02 18:00:35 +0300
commit806a4bf9e8581dda629eab2735795fbc579bd411 (patch)
tree485e69c098c387672d112a751820d629988b2705
parent62913b518d0fb99913e93314d9d4407730b7f32e (diff)
Move supersync worktime logic
-rw-r--r--fish/conf.d/supersync.fish67
-rw-r--r--fish/conf.d/worktime.fish71
2 files changed, 72 insertions, 66 deletions
diff --git a/fish/conf.d/supersync.fish b/fish/conf.d/supersync.fish
index 5a8db76..75d0c5e 100644
--- a/fish/conf.d/supersync.fish
+++ b/fish/conf.d/supersync.fish
@@ -1,40 +1,5 @@
set -x SUPERSYNC_STAMP_FILE ~/.supersync.last
-# Only sync the HabitsAndQuotes when it's asked for via function parameter
-function supersync::worktime
- set -l worktime_dir ~/git/worktime
-
- 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
-
function supersync::gitsyncer
set enable_file ~/.gitsyncer_enable
set now (date +%s)
@@ -76,43 +41,13 @@ function supersync::prompts
end
end
-function supersync::darwin_uprecords
- if test (uname) != Darwin
- return
- end
-
- set -l worktime_dir ~/git/worktime
- if not test -d $worktime_dir
- return
- end
-
- set -l uprecords_file
- for candidate in /opt/homebrew/var/uptimed/records /usr/local/var/uptimed/records
- if test -f $candidate
- set uprecords_file $candidate
- break
- end
- end
-
- if test -z "$uprecords_file"
- return
- end
-
- set -l target $worktime_dir/uprecords-(hostname).records
- cp $uprecords_file $target
- git -C $worktime_dir add $target
-end
-
function supersync
if test -f ~/.supersync_disable
echo Supersync is disabled
return
end
- supersync::worktime sync_quotes
- taskwarrior::invoke
- supersync::darwin_uprecords
- supersync::worktime no_sync_quotes
+ worktime::supersync
supersync::prompts
if test -f ~/.gos_enable
diff --git a/fish/conf.d/worktime.fish b/fish/conf.d/worktime.fish
index c1feb01..973645c 100644
--- a/fish/conf.d/worktime.fish
+++ b/fish/conf.d/worktime.fish
@@ -16,6 +16,77 @@ function worktime::sync
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
+
+function worktime::darwin_uprecords
+ if test (uname) != Darwin
+ return
+ end
+
+ if not test -d $WORKTIME_DIR
+ return
+ end
+
+ set -l uprecords_file
+ for candidate in /opt/homebrew/var/uptimed/records /usr/local/var/uptimed/records
+ if test -f $candidate
+ set uprecords_file $candidate
+ break
+ end
+ end
+
+ if test -z "$uprecords_file"
+ return
+ end
+
+ set -l target $WORKTIME_DIR/uprecords-(hostname).records
+ cp $uprecords_file $target
+ git -C $WORKTIME_DIR add $target
+
+ if type -q uprecords
+ set -l txt_target $WORKTIME_DIR/uprecords-(hostname).txt
+ uprecords >$txt_target
+ git -C $WORKTIME_DIR add $txt_target
+ end
+end
+
+function worktime::supersync
+ worktime::supersync_sync sync_quotes
+ taskwarrior::invoke
+ worktime::darwin_uprecords
+ 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