add task-note function to bin
This commit is contained in:
parent
fb48bf2d8d
commit
4a4d19e85c
|
@ -117,6 +117,7 @@
|
||||||
# task warrior
|
# task warrior
|
||||||
t = "task";
|
t = "task";
|
||||||
ta = "task add";
|
ta = "task add";
|
||||||
|
tn = "task-note";
|
||||||
tm = "task modify";
|
tm = "task modify";
|
||||||
te = "task edit";
|
te = "task edit";
|
||||||
ts = "task sync";
|
ts = "task sync";
|
||||||
|
@ -174,8 +175,9 @@
|
||||||
jtl = "journalctl";
|
jtl = "journalctl";
|
||||||
|
|
||||||
# quick ssh
|
# quick ssh
|
||||||
sm = "ssh 10.0.69.4";
|
kssh = "kitten +kitty ssh";
|
||||||
ss = "ssh sealight.xyz";
|
sm = "ssh 10.0.69.4"; # box over wireguard
|
||||||
|
ss = "ssh sealight.xyz"; # helix
|
||||||
sc = "ssh lakhwara.com"; # cube
|
sc = "ssh lakhwara.com"; # cube
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
52
users/profiles/desktop/bin/task-note.py
Normal file
52
users/profiles/desktop/bin/task-note.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""Manage Taskwarrior notes"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
NOTES_DIR = "~/kitaab/vimwiki/task-notes"
|
||||||
|
EDITOR = os.environ["EDITOR"]
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
def write_note(task_id: int):
|
||||||
|
"""Open `$EDITOR` to take notes about task with ID `task_id`."""
|
||||||
|
task_uuid = os.popen(f"task _get {task_id}.uuid").read().rstrip()
|
||||||
|
|
||||||
|
if not task_uuid:
|
||||||
|
logging.error(f"{task_id} has no UUID!")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
logging.debug(f"Task {task_id} has UUID {task_uuid}")
|
||||||
|
|
||||||
|
notes_dir = os.path.expanduser(NOTES_DIR)
|
||||||
|
os.makedirs(notes_dir, exist_ok=True)
|
||||||
|
notes_basename = f"{task_uuid}.md"
|
||||||
|
notes_file = os.path.join(notes_dir, notes_basename)
|
||||||
|
logging.debug(f"Notes file is {notes_file}")
|
||||||
|
|
||||||
|
if not os.path.exists(notes_file):
|
||||||
|
logging.info("Adding description to empty notes file")
|
||||||
|
task_description = os.popen(f"task _get {task_id}.description").read()
|
||||||
|
time = datetime.datetime.now().strftime("%y-%m-%d %H:%M")
|
||||||
|
|
||||||
|
with open(notes_file, "w") as f:
|
||||||
|
f.write(f"%title: {task_description}\n")
|
||||||
|
f.write(":task:\n")
|
||||||
|
f.write(f"%date: {time}\n\n")
|
||||||
|
f.flush()
|
||||||
|
|
||||||
|
os.execlp(EDITOR, EDITOR, notes_file)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(description="Write Taskwarrior notes")
|
||||||
|
parser.add_argument('task_id', metavar='ID', type=int, help="ID of the task to note")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
write_note(args.task_id)
|
|
@ -107,6 +107,7 @@ in
|
||||||
".local/bin/passmenu".source = ./bin/passmenu;
|
".local/bin/passmenu".source = ./bin/passmenu;
|
||||||
".local/bin/powermenu".source = ./bin/powermenu;
|
".local/bin/powermenu".source = ./bin/powermenu;
|
||||||
".local/bin/screenshot".source = ./bin/screenshot;
|
".local/bin/screenshot".source = ./bin/screenshot;
|
||||||
|
".local/bin/task-note".source = ./bin/task-note;
|
||||||
# ".local/bin/hotplug-monitor.sh".source = ./bin/hotplug-monitor.sh;
|
# ".local/bin/hotplug-monitor.sh".source = ./bin/hotplug-monitor.sh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue