aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--README.markdown4
-rwxr-xr-xbin/td56
-rw-r--r--man/man1/td.114
-rw-r--r--task/taskrc7
5 files changed, 72 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 7ba9936d..fd3e2551 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,6 @@
install-readline \
install-sh \
install-subversion \
- install-task \
install-terminfo \
install-tmux \
install-urxvt \
@@ -174,9 +173,6 @@ install-terminfo :
tic -- "$$info" ; \
done
-install-task :
- install -pm 0644 -- task/taskrc "$(HOME)"/.taskrc
-
install-tmux :
install -pm 0644 -- tmux/tmux.conf "$(HOME)"/.tmux.conf
diff --git a/README.markdown b/README.markdown
index b03ae954..12bf0b12 100644
--- a/README.markdown
+++ b/README.markdown
@@ -67,8 +67,6 @@ Configuration is included for:
for Perl
* [Readline](http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) — GNU
library for user input used by Bash, MySQL, and others
-* [Taskwarrior](http://taskwarrior.org/projects/show/taskwarrior) —
- Command-line task list manager
* [tmux](https://tmux.github.io/) — Terminal multiplexer similar to GNU
Screen
* [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html) — Fork of
@@ -287,6 +285,8 @@ Scripts
* `sue(8)` execs `sudoedit(8)` as the owner of all the file arguments given,
perhaps in cases where you may not necessarily have `root` `sudo(8)`
privileges.
+* `td(1)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used to
+ use Taskwarrior, but found it too complex and buggy.
* `try(1)` repeats a command up to a given number of times until it succeeds,
only printing error output if all three attempts failed. Good for
tolerating blips or temporary failures in `cron(8)` scripts.
diff --git a/bin/td b/bin/td
new file mode 100755
index 00000000..1c8828d2
--- /dev/null
+++ b/bin/td
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+#
+# td(1) -- Manage a to-do file with just $EDITOR and git(1), because I've
+# completely given up on finding a more useful way to do it.
+#
+# Author: Tom Ryder <tom@sanctum.geek.nz>
+# Copyright: 2016
+# License: Public domain
+#
+self=td
+
+# Specify the path to the file; you can override this with a $TODO environment
+# variable
+path=${TODO:-$HOME/Todo/todo.markdown}
+file=${path##*/}
+dir=${path%/*}
+
+# If the directory doesn't exist, create it
+if [[ ! -d $dir ]] ; then
+ mkdir -p -- "$dir" || exit
+fi
+
+# Change into the directory
+cd -- "$dir" || exit
+
+# Quick function to determine if a directory is a Git repository
+isrepo() {
+ { git symbolic-ref --quiet HEAD || \
+ git rev-parse --short HEAD
+ } >/dev/null 2>&1
+}
+
+# If the current directory isn't a Git repository, try to create one
+if ! isrepo ; then
+ git init || exit
+fi
+
+# If the to-do file doesn't exist yet, create it
+if ! [[ -e $file ]] ; then
+ touch -- "$file" || exit
+fi
+
+# Launch $VISUAL (or $EDITOR (or vi(1))), with any arguments given as options,
+# to edit the to-do file
+"${VISUAL:-${EDITOR:-vi}}" "$@" "$file"
+
+# Add the file to the changeset
+git add -- "$file"
+
+# If there are changes to commit, commit them
+message=$(printf 'Changed by %s(1)' "$self")
+if ! git diff-index --quiet HEAD ; then
+ git commit --message "$message" --quiet
+fi
+
diff --git a/man/man1/td.1 b/man/man1/td.1
new file mode 100644
index 00000000..74c64026
--- /dev/null
+++ b/man/man1/td.1
@@ -0,0 +1,14 @@
+.TH TD 1 "February 2016" "Manual page for td"
+.SH NAME
+.B td
+\- manage a to-do file
+.SH SYNOPSIS
+.B td [EDITOR_OPTS] [--]
+.SH DESCRIPTION
+Edit a to-do file with full path given in environment variable TODO (defaults
+to ~/Todo/todo.markdown), and automatically maintain a changelog via git(1).
+.SH SEE ALSO
+git(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
+
diff --git a/task/taskrc b/task/taskrc
deleted file mode 100644
index 46a629de..00000000
--- a/task/taskrc
+++ /dev/null
@@ -1,7 +0,0 @@
-data.location=~/.task
-dateformat=Y-M-D
-report.list.dateformat=Y-M-D
-report.long.dateformat=Y-M-D
-report.next.dateformat=Y-M-D
-weekstart=Monday
-