GothenburgBitFactory / taskwarrior

Taskwarrior - Command line Task Management
https://taskwarrior.org
MIT License
4.37k stars 297 forks source link

Allow tags to start with a number #1994

Closed jeffka11 closed 1 month ago

jeffka11 commented 6 years ago

I'd like to have a tag that starts with a number. In my use case, I like to tag a book's name to an action item. The book "4 Hour Workweek", currently requires +fourhrww where I'd like to use something like +4hww. Anyone that uses proper nouns, such as addresses or books, or abbreviations, could use this feature.

I know it's possible to use +ww4h or something that doesn't put the 4 in the beginning, but that's annoying to memorize and doesn't read from left to right like the title does.

olilau commented 6 years ago

Same issue for me. I wanted to add the '11.0' tag which is a software version but filters does not work when tags start by a number and I have to name these tags 'v11.0', ...

JessicaKMcIntosh commented 6 years ago

Same for me. We identify locations with numbers. I'm having to use things like "loc1234" for locations and "app2017" for versions. The strange thing is tags that are only numbers work in some places, but not others. Even when it's obvious by using the "+1234" syntax.

pbeckingham commented 6 years ago

Unless someone can show me how to support +N in a tag without it looking like a mathematical expressions, this isn't getting addressed.

JessicaKMcIntosh commented 6 years ago

Unfortunately I don't have a good solution. I looked at the parser but I don't know C++ so I could not figure it out. My only thought for this would be complicated and might not be possible. :(

pbeckingham commented 6 years ago

Agreed.

ddombrowsky commented 4 years ago

is there any way to force it? Maybe task +1one won't ever work, but is there no way around the limitation?

olilau commented 4 years ago

You can create a hook. Here is one that should work:

import sys
import json
import re

added_task = json.loads(sys.stdin.readline())

tags = added_task.get("tags", [])
all_words = added_task['description'].split(' ')
real_words = []
for t in all_words:
    if t.startswith("+"):
        tags.append(t.replace('+', '', 1))
    else:
        real_words.append(t)
added_task['description'] = " ".join(real_words)
added_task['tags'] = tags
print(json.dumps(added_task))

sys.exit(0)

Not 100% perfect but I'm using it for the same purpose and I'm quite happy with it. You can place it in ~/.task/hooks/on-add-replace-tags.py

ddombrowsky commented 3 years ago

Actually, I'm not sure why using the tag: syntax when the tag starts with a number wouldn't work.

e.g.

$ t add project:6sr tag:6sr "6SR: look into helping taskwarrior"
Created task 53.
The project '6sr' has changed.  Project '6sr' is 50% complete (1 of 2 tasks remaining).
$ t tag:6sr
[task next ( tag:6sr )]

ID UUID     Age Project Tag Description                        Urg 
53 db7d176c 12s 6sr     6sr 6SR: look into helping taskwarrior  1.8

1 task
olilau commented 3 years ago

It seems to work now (without any hooks).

felixschurk commented 1 month ago

Also in v3.1.0 its working to have tags starting with a number.