aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-07-11 16:19:20 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-07-11 16:19:20 +1200
commit42ff64e5c91d22660d8538b4d329b842a5451b9d (patch)
tree382d4b3e28b981340aa98f1886d9ed46b4d0d601
parentMerge branch 'release/v6.55.0' into develop (diff)
downloaddotfiles-42ff64e5c91d22660d8538b4d329b842a5451b9d.tar.gz
dotfiles-42ff64e5c91d22660d8538b4d329b842a5451b9d.zip
Extend td(1df) to edit multiple files
-rw-r--r--bin/td.sh18
-rw-r--r--man/man1/td.1df7
2 files changed, 13 insertions, 12 deletions
diff --git a/bin/td.sh b/bin/td.sh
index ef0be618..a5a4ab30 100644
--- a/bin/td.sh
+++ b/bin/td.sh
@@ -2,7 +2,6 @@
# Specify the path and file
dir=${TODO_DIR:-"$HOME"/Todo}
-file=${1:-"${TODO_NAME:-todo}"}
# If the directory doesn't exist, create it
[ -d "$dir" ] || mkdir -p -- "$dir" || exit
@@ -17,15 +16,16 @@ if ! command -v isgr >/dev/null 2>&1 ; then
fi
isgr || git init --quiet || exit
-# If the to-do file doesn't exist yet, create it
-[ -e "$file" ] || touch -- "$file" || exit
+if [ "$#" -eq 0 ] ; then
+ set -- "${TODO_NAME:-todo}"
+fi
-# Launch an appropriate editor to edit that file
-"${VISUAL:-"${EDITOR:-ed}"}" "$file"
+# Launch an appropriate editor to edit those files
+"${VISUAL:-"${EDITOR:-ed}"}" "$@"
-# Add the file to the changeset
-git add -- "$file"
+# Add those files to the changeset
+git add -- "$@"
-# If there are changes to commit, commit them
-git diff-index --quiet HEAD 2>/dev/null ||
+# If there are changes to those files to commit, commit them
+git diff-index --quiet HEAD "$@" 2>/dev/null ||
git commit --message 'Changed by td(1df)' --quiet
diff --git a/man/man1/td.1df b/man/man1/td.1df
index df1ff82f..86d463cb 100644
--- a/man/man1/td.1df
+++ b/man/man1/td.1df
@@ -1,12 +1,13 @@
-.TH TD 1df "June 2016" "Manual page for td"
+.TH TD 1df "July 2019" "Manual page for td"
.SH NAME
.B td
\- manage to-do files
.SH SYNOPSIS
-.B td [FILENAME]
+.B td [FILENAME...]
.SH DESCRIPTION
Edit to-do files in ~/Todo, defaulting to a file just named "todo",
-automatically maintaining a changelog via git(1).
+automatically maintaining a changelog via git(1). Multiple filenames are
+accepted.
.SH SEE ALSO
git(1)
.SH AUTHOR