Created
March 27, 2015 11:13
-
-
Save jcsjcs/1602671727ce88c65b2a to your computer and use it in GitHub Desktop.
Script for opening a task file for today and the most recent task file in vim.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Inspired by Jamis Buck's blog entry: | |
# http://weblog.jamisbuck.org/2015/3/17/task-tracking-for-neurochemical-brains.html | |
# Go to tasks folder and open (or create) today's task file | |
# and the previous task file in vim. | |
cd ~/tasks | |
TODAY="tasks_`date '+%Y_%m_%d'`.txt" | |
# Get the last two task files by date. | |
arr=( $(ls -1 tasks_* | sort -r | head -n2) ) | |
# Remove the first or last element in the array depending on the | |
# existence of today's task file. | |
if [ ${#arr[@]} -gt 1 ]; then | |
if [ $TODAY = ${arr[0]} ]; then | |
unset arr[0] | |
else | |
unset arr[1] | |
fi | |
fi | |
# Use -n to open vim without creating swap files. | |
vim -n $TODAY ${arr[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment