• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    Shell
  • Created almost 13 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bash function for displaying next actions in plain-text files per project directory

na is a script designed to make it easy to see what your next actions are for any project, right from the command line. It works with TaskPaper-formatted files (but any plain text format will do), looking for @na tags (or whatever you specify) in todo files in your current folder.

Used with Taskpaper files, it can add new todo items quickly from the command line, automatically tagging them as next actions.

It can also auto-display next actions when you enter a project directory, automatically locating any todo files and listing their next actions when you cd to the project (optionally recursive).

Features

You can list next actions in files in the current directory by typing na. By default, na looks for *.taskpaper files and extracts items tagged @na and not @done. All of these can be changed in the configuration.

Easy matching

na features intelligent project matching. Every time it locates a todo file, it adds the project to the database. Once a project is recorded, you can list its actions by using any portion of the parent directories names. If your project is in ~/Sites/dev/markedapp, you could quickly list its next actions by typing na dev mark. It will always look for the shortest match.

Recursion

na can also recurse subdirectories to find all todo files in child folders as well. Use the -r switch to do a recursive search on the current directory. na -r with no arguments will recurse from your current location, looking for todo files in all subdirectories.

Maximum depth for recursion can be controlled in the config (default is 4). na -r can take a path or project title fragments as arguments as well, and will recurse from the matched directory. A configuration option allows you to have the auto-display recurse by default.

Adding todos

You can also quickly add todo items from the command line with the -a switch. The script will look for a file in the current directory called todo.taskpaper (or whatever extension you've set).

If found, it will try to locate an Inbox: project, or create one if it doesn't exist. Any arguments after -a will be combined to create a new task in TaskPaper format. They will automatically be assigned as next actions (tagged @na) and will show up when na lists the tasks for the project.

Installation

  1. Get the script here: https://github.com/ttscoff/na/blob/master/na
  2. Place na in a folder in your path and ensure that it's executable with chmod a+x /path/to/na.

The cache of used directories is stored in ~/.tdlist. I haven't made this configurable yet.

Usage

-r recurse 3 directories deep and concatenate all $NA_TODO_EXT files -a [todo] add a todo to todo.$NA_TODO_EXT in the current dir -n with -a, prompt for a note after reading task -t specify an alternate tag (default @na) pass empty quotes to apply no automatic tag -p [X] add a @priority(X) tag (with -a) -v search for tag with specific value (requires -t) -h show a brief help message

  • Add todos
    • na -a ["todo item"]: add new todo to project's .taskpaper file inbox in the current folder
      • If no "todo item" is specified, it will prompt you for input
      • -n: used with -a, prompt for a note after reading task
      • -t: specify an alternate tag (default @na)
        • Pass empty quotes to apply no automatic tag
        • You can add additional @tags in the task description
      • -p [X] add a @priority(X) tag
  • List todos
    • na lists all next actions in the current folder's taskpaper file
      • na caches folders it's used in, so you can use an optional argument to match the dirname of another folder (na marked)
      • -t (without -a) search for a specific tag
        • -v search for a tag with a specific value, e.g. na -t priority -v 5
      • -p (without -a) search for items with a specific priority value (shortcut for na -t priority -v X)
    • -r (recurse and concatenate @na in todo files up to 3 levels deep, works with optional argument to list another folder)
    • for na and na -r, additional arguments are parsed for best (and shortest) project match
  • Auto-list todos when changing directory
    • only triggers on directory change command (cd,z,j,g,f)
    • turn off auto-display entirely in the config
    • set whether or not to auto-display recursively in the config
  • Help
    • -h (display help)

Examples

  • na: list next actions in the current directory
  • na -r: list next actions recursively from the current directory
  • na ~: list next actions in your home folder
  • na -r ~ list next actions recursively from home
  • na dev mark: list next actions in a project located in ~/Sites/dev/marked2app
  • na -a "Update documentation": create a new next action in the Inbox: project of todo.taskpaper in the current folder

Configuration

You can configure na by setting environment variables before you source it.

Here are the default values, for reference:

export NA_TODO_EXT=taskpaper
export NA_NEXT_TAG=@na
export NA_DONE_TAG=@done
export NA_MAX_DEPTH=3

Auto-listing todos on PWD change

You can add a prompt command to your shell to have na automatically list your next actions when you cd into a directory. Add the appropriate command to your login file for your shell:

Bash (in ~/.bash_profile):

if [[ -z "$PROMPT_COMMAND" ]]; then
	PROMPT_COMMAND="eval 'na --prompt'"
else
	echo $PROMPT_COMMAND | grep -v -q "na --prompt" && PROMPT_COMMAND="$PROMPT_COMMAND;"'eval "na --prompt"'
fi

Fish (in ~/.config/fish/conf.d/*.fish):

function __should_na --on-variable PWD
	# function __should_na --on-event fish_prompt
	test -s (basename $PWD)".taskpaper" && na
end

Zsh (in ~/.zshrc):

chpwd() { na }

Misc

If you have gum installed, na will use it for command line input when adding tasks and notes.

More Repositories

1

doing

Ruby
1,036
star
2

mdless

Ruby
787
star
3

Slogger

Social logging script for Day One
Ruby
762
star
4

KeyBindings

DefaultKeybindings.dict for Mac OS X
HTML
689
star
5

cheaters

Customizable cheat sheet system for OS X
HTML
461
star
6

popclipextensions

Brett's PopClip Extensions
Python
431
star
7

MarkedCustomStyles

Custom Style Repository for Marked2.app
CSS
416
star
8

QuickQuestion

A simple, text-based system for building an easily-searchable knowlegebase on OS X. CLI, LaunchBar and Alfred included.
Shell
188
star
9

Brett-s-TextExpander-Snippets

General-use snippets for TextExpander on Mac
PHP
129
star
10

fish_files

Shell
125
star
11

OTask

Ruby CLI for OmniFocus
Ruby
122
star
12

nvremind

A scheduled background task to scan nvALT notes for @reminder() tags and trigger notifications based on dates.
Ruby
98
star
13

bunch

Documentation repository for Bunch.app
Ruby
88
star
14

vitag

Ruby
86
star
15

hookapp

HTML
81
star
16

Pinboard-to-OpenMeta

Saves Pinboard bookmarks as local webloc files on a Mac. Can add thumbnails and save PDF's, with external apps. Works with Tags.app or the OpenMeta cli utility.
Ruby
79
star
17

gather-cli

Swift
73
star
18

JekyllPlugins

A small collection of (often lame) Jekyll plugins
SCSS
65
star
19

ubersicht-widgets

CoffeeScript
62
star
20

niftymenu

JavaScript
59
star
21

hook_goodies

AppleScript
59
star
22

snibbets

Ruby
46
star
23

where

Shell
38
star
24

BetterTouchTool-Widgets

Ruby
38
star
25

searchlink

Ruby
34
star
26

howzit_old

Ruby
32
star
27

ExtraInfoPlus

AppleScript
32
star
28

blogsmith-tmbundle

TextMate bundle for blogging platforms with poor/no xmlrpc support
Ruby
31
star
29

bookmark-cli

CLI for OS X that returns a base64 string of bookmark data for a file, or locates a file given a base64 string
Objective-C
31
star
30

popupsCSS

iOS-esque popup styles
28
star
31

jquery-tldr

JavaScript
26
star
32

dotfiles

Various config files
Shell
24
star
33

tagbak

Ruby
24
star
34

nvWikiLink

Universal system for creating plain text wiki links to nvALT notes
Ruby
22
star
35

sidecar

Sidecar jacket for Simplify
HTML
19
star
36

jtag

Ruby
19
star
37

coughbutton

An iPhone-based cough button for your Mac using PHP and MuteMyMic
JavaScript
18
star
38

delimport-pinboard

Index your Pinboard bookmarks using Spotlight on Mac OS X.
Objective-C
18
star
39

CodeReminder

Ruby
17
star
40

MarkdownURLs.safariextension

The source for the TabLinks Safari Extension
JavaScript
16
star
41

na_gem

a command line tool for adding and listing project todos
Ruby
16
star
42

mmd2cheatset

Ruby
16
star
43

howzit

Ruby
14
star
44

notehub

Ruby
14
star
45

reiki

Shell
13
star
46

Character-pair-autocompletion

Character pair autocomplete is now possible on any Mac app using these TextExpander custom snippets including on selected text.
13
star
47

ttscoff.github.com

Brett Terpstra's GitHub website
CSS
12
star
48

bunchcli

Ruby
12
star
49

Twilight2.tmTheme

A mod of the classic Twilight theme for TextMate and Sublime Text
11
star
50

starter-book

An online book.
11
star
51

Sublime-Bunch

Bunch is a Mac automation app that runs on plain text files with the extension `.bunch`. It has its own "language", and this package provides syntax highlighting for Bunch files, as well as light/dark color schemes, snippets for common commands, and completion for app names.
Python
10
star
52

VSCode-Bunch

9
star
53

podtagger

Automated ID3 tagging for podcasts
Ruby
9
star
54

TextBuddyScripts

JavaScript
9
star
55

TabLinks

HTML
8
star
56

loadbar

CoffeeScript
8
star
57

LuckyCharms-tmTheme

A light theme for Sublime Text, VS Code, and Vim
Vim Script
8
star
58

fuzzy_cd

Shell
6
star
59

MailMateMate.mmBundle

Ruby
6
star
60

quix-mann

Merlin Mann's Custom Quix Commands
6
star
61

bookmarklets

Repo to run bookmarklets from inline scripts on github.com
JavaScript
5
star
62

omf-fuzzy_cd

Shell
4
star
63

EditScript

Ruby
3
star
64

marky-api

SCSS
2
star
65

itunescontrol-tmbundle

iTunes Controller for TextMate, highly experimental
Ruby
2
star
66

Dictionary-tmbundle

Various dictionary, spellchecking and thesaurus commands for TextMate
2
star
67

omf-packages

1
star
68

Marked

Marked.app - MultiMarkdown Preview Everywhere
1
star
69

homebrew-thelab

Ruby
1
star
70

htmlexperiments

Just dicking around
1
star