summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-20 12:07:13 +0300
committerPaul Buetow <paul@buetow.org>2025-04-20 12:07:13 +0300
commit50fcf0511967ad6ebcdf59b5258d6d9856678693 (patch)
treefffc72d4f5a113a8406e6a4a6607abc677b06042
parent28796839653111d8e042db9b06d3e9660b63a8b5 (diff)
new stuff
-rw-r--r--dotfiles/fish/conf.d/fuzzy.fish5
-rw-r--r--dotfiles/fish/conf.d/sync.fish90
-rw-r--r--dotfiles/fish/conf.d/taskwarrior.fish90
3 files changed, 185 insertions, 0 deletions
diff --git a/dotfiles/fish/conf.d/fuzzy.fish b/dotfiles/fish/conf.d/fuzzy.fish
new file mode 100644
index 0000000..7683a0e
--- /dev/null
+++ b/dotfiles/fish/conf.d/fuzzy.fish
@@ -0,0 +1,5 @@
+function __tv_git
+ tv git-repos
+end
+
+bind \cg __tv_git
diff --git a/dotfiles/fish/conf.d/sync.fish b/dotfiles/fish/conf.d/sync.fish
new file mode 100644
index 0000000..8364a57
--- /dev/null
+++ b/dotfiles/fish/conf.d/sync.fish
@@ -0,0 +1,90 @@
+set -x SYNC_STAMP_FILE ~/.sync.last
+
+function sync::is_it_time_to_sync
+ set -l max_age 86400
+ set -l now (date +%s)
+ if test -f $SYNC_STAMP_FILE
+ set -l diff (math $now - (cat $SYNC_STAMP_FILE))
+ if test $diff -lt $max_age
+ return 0
+ end
+ end
+ echo 'It is time to run sync!!!'
+end
+
+# Only sync the HabitsAndQuotes when it's asked for via function parameter
+function sync::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/HabitsAndQuotes/{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/HabitsAndQuotes/Exercise.md >exercises.md
+ git add exercises.md
+ end
+ end
+
+ find . -name '*.txt' -exec git add {} \;
+ find . -name '*.json' -exec git add {} \;
+ git commit -a -m sync
+
+ git pull origin master
+ git push origin master
+
+ cd -
+end
+
+function sync::uprecords
+ set -l uprecords_dir ~/git/uprecords
+ set -l uprecords_repo git@codeberg.org:snonux/uprecords.git
+
+ if not test -d $uprecords_dir
+ git clone $uprecords_repo $uprecords_dir
+ cd $uprecords_dir
+ else
+ cd $uprecords_dir
+ git pull
+ end
+
+ make update
+ git commit -a -m Update
+ git push
+ cd -
+end
+
+function sync::taskwarrior
+ if test -f ~/scripts/taskwarriorfeeder.rb
+ ruby ~/scripts/taskwarriorfeeder.rb
+ else
+ echo "No taskwarrior feeder script, skipping"
+ end
+
+ taskwarrior::export
+ taskwarrior::import
+end
+
+function sync
+ sync::worktime sync_quotes
+ sync::taskwarrior
+ sync::worktime no_sync_quotes
+ sync::uprecords
+
+ if which gos >/dev/null
+ gos
+ end
+
+ date +%s >$SYNC_STAMP_FILE.tmp
+ mv $SYNC_STAMP_FILE.tmp $SYNC_STAMP_FILE
+end
diff --git a/dotfiles/fish/conf.d/taskwarrior.fish b/dotfiles/fish/conf.d/taskwarrior.fish
new file mode 100644
index 0000000..ae375e4
--- /dev/null
+++ b/dotfiles/fish/conf.d/taskwarrior.fish
@@ -0,0 +1,90 @@
+function taskwarrior::due::count
+ set -l due_count (task status:pending due.before:now count)
+ if test $due_count -gt 0
+ echo "There are $due_count tasks due!"
+ end
+end
+
+function taskwarrior::url::open
+ taskwarrior::select $argv[1]
+ set -l desc (task +track status:pending export | jq -r '.[].description')
+ set -l url (extractUrlFromString "$desc")
+ if test (uname) = Darwin
+ open -a "Google Chrome" "$url"
+ else if test (uname) = Linux
+ xdg-open "$url"
+ end
+end
+
+function extractUrlFromString
+ set -l str "$argv[1]"
+ set -l regex "(https?://[a-zA-Z0-9.-]+(/[a-zA-Z0-9._%+-/?&=]*))"
+ echo $str | string match -r $regex
+end
+
+function taskwarrior::add::track
+ if test (count $argv) -gt 0
+ task add priority:L +personal +track $argv due:eow
+ else
+ vit +track
+ end
+end
+
+function taskwarrior::add::standup
+ if test (count $argv) -gt 0
+ task add priority:L +work +standup +sre +nosched $argv
+ task add priority:L +work +standup +storage +nosched $argv
+ else
+ vit +standup
+ end
+end
+
+function taskwarrior::add::standup::editor
+ set -l tmpfile (mktemp /tmp/standup.XXXXXX.txt)
+ $EDITOR $tmpfile
+ taskwarrior::add::standup (cat $tmpfile)
+end
+
+function _taskwarrior::set_import_export_tags
+ if test (uname) = Darwin
+ set -gx TASK_IMPORT_TAG work
+ set -gx TASK_EXPORT_TAG personal
+ else
+ set -gx TASK_IMPORT_TAG personal
+ set -gx TASK_EXPORT_TAG work
+ end
+end
+
+function taskwarrior::export
+ _taskwarrior::set_import_export_tags
+ set -l count (task +$TASK_EXPORT_TAG status:pending count)
+ if test $count -eq 0
+ return
+ end
+ echo "Exporting $count tasks to $TASK_EXPORT_TAG"
+ task +$TASK_EXPORT_TAG status:pending export >"$WORKTIME_DIR/tw-$TASK_EXPORT_TAG-export-"($DATE +%s)".json"
+ yes | task +$TASK_EXPORT_TAG status:pending delete
+end
+
+function taskwarrior::import
+ _taskwarrior::set_import_export_tags
+ find $WORKTIME_DIR -name "tw-$TASK_IMPORT_TAG-export-*.json" | while read -l import
+ task import $import
+ rm $import
+ end
+ find $WORKTIME_DIR -name "tw-(hostname)-export-*.json" | while read -l import
+ task import $import
+ rm $import
+ end
+end
+
+abbr -a t task
+abbr -a tdue 'vit status:pending due.before:now'
+abbr -a thome 'vit +home'
+abbr -a tasks 'vit -track'
+abbr -a V 'taskwarrior::add::standup'
+abbr -a Vstorage 'vit +standup +storage'
+abbr -a Vsre 'vit +standup +sre'
+abbr -a Ved 'taskwarrior::add::standup::editor'
+abbr -a track 'taskwarrior::add::track'
+abbr -a T 'taskwarrior::add::track'