From 15015e61e0509d13c68ad7f7c1ea33250bbafd87 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 8 Mar 2025 19:32:50 +0100 Subject: [PATCH 1/7] nvim: Add neowarrior plugin Allows quickly listing and working with taskwarrior tasks from within neovim. Show a floating `:NeoWarriorOpen` window with `sw` or a vertical neowarrior buffer with `sW`. --- nvim/.config/nvim/lua/plugins/task.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 nvim/.config/nvim/lua/plugins/task.lua diff --git a/nvim/.config/nvim/lua/plugins/task.lua b/nvim/.config/nvim/lua/plugins/task.lua new file mode 100644 index 0000000..3ed2b94 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/task.lua @@ -0,0 +1,26 @@ +return { + { + "duckdm/neowarrior.nvim", + branch = "develop", + -- event = {"CursorHold", "InsertEnter"}, + dependencies = { + --- Optional but recommended for nicer inputs + --- 'folke/noice.nvim', + }, + --- See config example below + opts = {}, + cmd = { + "NeoWarriorOpen", + "NeoWarriorAdd", + "NeoWarriorDone", + "NeoWarriorFilter", + "NeoWarriorFilterSelect", + "NeoWarriorReport", + "NeoWarriorRefresh", + }, + keys = { + { "sw", ":NeoWarriorOpen float", desc = "open neowarrior", silent = true }, + { "sW", ":NeoWarriorOpen right", desc = "open neowarrior", silent = true }, + }, + }, +} From d2be1c87950a856bf6359aed88ddb02a4bdfd4cc Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 9 May 2025 22:08:21 +0200 Subject: [PATCH 2/7] nvim: Change mapping for printing Fidget message history Since it is technically vim-internal (and relatively rarely used unless to debug things), I have moved the shortcut for this function from `sh` (show-history) to `vp` (vim-print-messages). The 'p'-suffix is a little unfortunate but currently h/H/m are all taken in this vim-internal submenu. The reasoning behind this is that the 'show' menu is intended primarily for user-facing, middle-of-work tasks and windows that help me accomplish goals when actually working and getting things done. Showing the fidget history does not do that, but allows introspection into the vim editor history. So, it should accordingly live under the 'vim' menu. Additionally, it frees space in the 'show' menu and lets me/the user forget about the functionality until it is needed. --- nvim/.config/nvim/lua/plugins/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua index e8f1d60..22e5b26 100644 --- a/nvim/.config/nvim/lua/plugins/ui.lua +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -14,7 +14,7 @@ return { event = { "VeryLazy" }, cmd = { "Fidget" }, keys = { - { "sh", "Fidget history", { silent = true, desc = "show notification history" } }, + { "vp", "Fidget history", { silent = true, desc = "print message history" } }, }, }, -- make all vim.ui interfaces prettyy From d1f4c4ab8f95b021b80d94ba8f7848ca853f95d0 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 9 May 2025 21:53:53 +0200 Subject: [PATCH 3/7] task: Remove taskwarrior hooks Taskwarrior hooks are removed from this general dotfiles repo, as they are instead included in my taskwarrior 'task' folder (and project) itself. Each hook belongs to exactly one taskwarrior repository and thus they should also exist there and not anywhere else, is my current opinion. This is especially so since I believe most people use exactly one taskwarrior repository (me included). So for the moment it just makes the most sense to have these two things live side-by-side instead of in this more general configuration repository. --- .../share/task/hooks/on-exit.git-backup | 77 ------------- .../share/task/hooks/on-modify.timewarrior | 102 ------------------ 2 files changed, 179 deletions(-) delete mode 100755 office/.local/share/task/hooks/on-exit.git-backup delete mode 100755 office/.local/share/task/hooks/on-modify.timewarrior diff --git a/office/.local/share/task/hooks/on-exit.git-backup b/office/.local/share/task/hooks/on-exit.git-backup deleted file mode 100755 index e80cbe2..0000000 --- a/office/.local/share/task/hooks/on-exit.git-backup +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# Automatically git commits, pushes and pulls if doable in the taskwarrior data directory -# -# Much of this taken from: https://github.com/mrschyte/taskwarrior-hooks/ -# with much gratitude -# -# The minimum amount of time required between 2 commits in seconds. -# So only if the last commit is at least x seconds old will a new one -# be created. Set to 0 to sync each taskwarrior change. -MINIMUM_WAIT_TIME=60 - -# Do not display status information. -QUIET=true - -# Removes the tasks.json file after each run, keeping the -# task directory clean. -REMOVE_JSON=false - -# Sort with `jq` commandline program if it is found. -# Also drops extra values 'urgency' and 'id' which are not -# necessary for backups and automatically calculated by tw. -STABLE_JSON=true - -if [ "${DISABLE_HOOKS}" = "true" ] || ! command -v git >/dev/null 2>&1; then - exit 0 -fi - -if [ "$1" != "api:2" ]; then - printf "Taskwarrior uses different data API version than git plugin. Aborting!" 1>&2 - exit 1 -fi - -data_dir="$(echo "$5" | cut -f2 -d:)" -command_run="$(echo "$3" | cut -f2 -d:)" - -if [ "$command_run" = "synchronize" ]; then - DISABLE_HOOKS=true env task sync - - git -C "$data_dir" pull >/dev/null 2>&1 - pull_ret="$?" - git -C "$data_dir" push >/dev/null 2>&1 - push_ret="$?" - if [ "$pull_ret" -eq 0 ] && [ "$push_ret" -eq 0 ]; then - [ $QUIET = "true" ] || echo "Git upstream synchronized." - fi -fi - -last_commit=$(git -C "$data_dir" log -1 --format="%at") -# if now is not yet greater than last commit + wait time do nothing -if [ "$(date "+%s")" -lt $((last_commit + MINIMUM_WAIT_TIME)) ]; then - # TODO: Implement DEBUG msg level (info/debug) system - # echo "Too early to check for changes, exiting." - exit 0 -fi - -# echo "EXPORTING TASKS" -if [ "$STABLE_JSON" = true ] && command -v jq >/dev/null 2>&1; then - DISABLE_HOOKS=true env task export | jq -S 'map(del(.id, .urgency)) | sort_by(.entry, .modified) | reverse' >"$data_dir/tasks.json" -else - DISABLE_HOOKS=true env task export >"$data_dir/tasks.json" -fi - -# after any command, if there's changes add and commit -if ! git -C "$data_dir" diff --exit-code >/dev/null 2>&1; then - # echo "found changes" - # need to run to fully update tasks that just got done - DISABLE_HOOKS=true env task next >/dev/null 2>&1 - - header="auto: ${2##* }" - msg="full command: $2" - git -C "$data_dir" commit "$data_dir/tasks.json" -m "$header" -m "$msg" --no-gpg-sign >/dev/null 2>&1 - [ $QUIET = "true" ] || echo "Backup up to git." -fi - -if [ "$REMOVE_JSON" = true ] && [ -f "$data_dir/tasks.json" ]; then - rm "$data_dir/tasks.json" >/dev/null 2>&1 -fi diff --git a/office/.local/share/task/hooks/on-modify.timewarrior b/office/.local/share/task/hooks/on-modify.timewarrior deleted file mode 100755 index 61a16e5..0000000 --- a/office/.local/share/task/hooks/on-modify.timewarrior +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python3 - -############################################################################### -# -# Copyright 2016 - 2021, Thomas Lauf, Paul Beckingham, Federico Hernandez. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# https://www.opensource.org/licenses/mit-license.php -# -############################################################################### - -from __future__ import print_function - -import json -import subprocess -import sys - -# Hook should extract all of the following for use as Timewarrior tags: -# UUID -# Project -# Tags -# Description -# UDAs - -try: - input_stream = sys.stdin.buffer -except AttributeError: - input_stream = sys.stdin - -# Make no changes to the task, simply observe. -old = json.loads(input_stream.readline().decode("utf-8", errors="replace")) -new = json.loads(input_stream.readline().decode("utf-8", errors="replace")) -print(json.dumps(new)) - - -def extract_tags_from(json_obj): - # Extract attributes for use as tags. - tags = [json_obj['description']] - - if 'project' in json_obj: - tags.append(f"#{json_obj['project']}") - - if 'tags' in json_obj: - tags.extend([f"+{tag}" for tag in json_obj['tags']]) - - return tags - - -def extract_annotation_from(json_obj): - - if 'annotations' not in json_obj: - return '\'\'' - - return json_obj['annotations'][0]['description'] - - -start_or_stop = '' - -# Started task. -if 'start' in new and 'start' not in old: - start_or_stop = 'start' - -# Stopped task. -elif ('start' not in new or 'end' in new) and 'start' in old: - start_or_stop = 'stop' - -if start_or_stop: - tags = extract_tags_from(new) - - subprocess.call(['timew', start_or_stop] + tags + [':yes']) - -# Modifications to task other than start/stop -elif 'start' in new and 'start' in old: - old_tags = extract_tags_from(old) - new_tags = extract_tags_from(new) - - if old_tags != new_tags: - subprocess.call(['timew', 'untag', '@1'] + old_tags + [':yes']) - subprocess.call(['timew', 'tag', '@1'] + new_tags + [':yes']) - - old_annotation = extract_annotation_from(old) - new_annotation = extract_annotation_from(new) - - if old_annotation != new_annotation: - subprocess.call(['timew', 'annotate', '@1', new_annotation]) From f68a62f3778d97b4eaf9bfe624742c6a8f884c6e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 9 May 2025 21:53:53 +0200 Subject: [PATCH 4/7] task: Add aliases for showing tasks done Can show tasks accomplished today (tdd, 'Task Done toDay'), since yesterday (tdy, 'Task Done since Yesterday'), or in the last week (tdw, 'Task Done in the Week'). --- office/.config/sh/alias.d/taskwarrior.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/office/.config/sh/alias.d/taskwarrior.sh b/office/.config/sh/alias.d/taskwarrior.sh index ad7c6ff..c69b7ac 100644 --- a/office/.config/sh/alias.d/taskwarrior.sh +++ b/office/.config/sh/alias.d/taskwarrior.sh @@ -29,7 +29,9 @@ if exist timew; then else alias tra="task active" fi -alias trw="task end.after:today-1wk completed" +alias tdd="task end.after:today all" # done doday +alias tdy="task end.after:yesterday all" # done yesterday-today +alias tdw="task end.after:today-1wk completed" # done this week alias tad="task +ACTIVE done" alias tas="task +ACTIVE stop" From 7d9a85ec4892f9204e5fb17e47723054cb168ae5 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 9 May 2025 21:53:53 +0200 Subject: [PATCH 5/7] jj: Remove deprecated git subprocess configuration Since jj moved to use git as a subprocess by default a couple versions ago, they now deprecated the git.subprocess configuration option (jj version 0.29). This commit removes it. --- vcs/jj/config/jj/config.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/vcs/jj/config/jj/config.toml b/vcs/jj/config/jj/config.toml index 9d5368f..8bfa504 100644 --- a/vcs/jj/config/jj/config.toml +++ b/vcs/jj/config/jj/config.toml @@ -8,7 +8,6 @@ key = "73BA40D5AFAF49C9" [git] sign-on-push = true -subprocess = true private-commits = "description(glob-i:'WIP:*') | description(glob-i:'PRIVATE:*')" # refuse to push WIP commits [ui] From 4dc4ab39a6f5a17be484a99fa595ba634a09c65c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 15 May 2025 11:47:01 +0200 Subject: [PATCH 6/7] jj: Add alias to show WIP commits. `jlfw` will quickly list every commit that contains 'WIP:'. Quicker version of `jlf 'WIP:'`. --- vcs/jj/config/sh/alias.d/jj.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh index 60f8025..8a3d48e 100644 --- a/vcs/jj/config/sh/alias.d/jj.sh +++ b/vcs/jj/config/sh/alias.d/jj.sh @@ -65,6 +65,7 @@ jlof() { jloof() { jj log --patch -r "description(substring-i:\"$*\")" } +alias jlfw='jj log -r "description(substring-i:\"WIP:\")"' # show branches (i.e. head commits) w a couple previous commits alias jh="jj log -r 'ancestors(heads(all()), 3)'" From 83e2b9f31bc9c922cf264ce8a748d7b4efbb782d Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 22 May 2025 13:06:02 +0200 Subject: [PATCH 7/7] jj: Add alias to list all bookmarks --- vcs/jj/config/sh/alias.d/jj.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh index 8a3d48e..02e37d3 100644 --- a/vcs/jj/config/sh/alias.d/jj.sh +++ b/vcs/jj/config/sh/alias.d/jj.sh @@ -74,7 +74,8 @@ alias jrb="jj rebase" # 'branching' bookmark work alias jb="jj bookmark" -jbm() { +alias jbl="jj bookmark list" +jbm() { # set 'main' bookmark to current or given change jj bookmark set -r "${1:-@}" main }