如何在Taskwarrior上用一個指令新增多個任務?

如何在Taskwarrior上用一個指令新增多個任務?

如何在一個命令列中新增多個任務任務戰士

我想實現類似的目標:

task add task1 tag:tag1, task2 tag:tag2

我認為應該有一個分隔符號來分隔任務。

答案1

如果您實際上只需要在一行中執行此操作,您可以這樣做:

task add "Get some foo"; task add "Get some bar"

這僅使用;shell 本機的令牌。

答案2

不知道你是否還對此感興趣。我創建了一個非常快速的 bash shell 腳本,非常適合我當時的目的。它會詢問您是否要為任務設定項目或標籤,然後快速建立多個新任務。使用了一些相當響亮的顏色組合,我想我當時才剛發現“echo -e”方法;o)

我今天在搜尋並找到了你的帖子,因為我想開發腳本來執行依賴項,但看起來我可能必須學習 python;我還想做一些谷歌提醒同步。如果您找到了一個好的工具,那麼我很高興知道您選擇了哪種解決方案。

克爾A


#!/bin/bash

#  Script:  twmulti
#  Created: 2016.02.11
#  Current: ~/Bin

#   clear the variables just in case a recent session set them
PRJNAME=""
TAGNAME=""
TSKNAME=""

clear

echo -e "\e[1;33;41mENTER PROJECT NAME >\e[0;m" 
read PRJNAME
if [ -z $PRJNAME ] ; then PRJNAME="" ; fi

echo -e "\n\e[1;33;41mENTER ANY TAG(S)  >\e[0;m" 
read TEMPTAGNAME
TAGNAME="+"`echo $TEMPTAGNAME | sed 's/ / +/g'`
if [ -z $TEMPTAGNAME ] ; then TAGNAME=""; fi

while :
do
    clear 
    echo -e "\e[1;33;41mENTER TASK DESCRIPTION (Project:$PRJNAME) >\e[0;m"
    echo -e "\e[1;33;41mor enter again to quit\e[0;m"
    read TSKNAME
        if [ -z $TSKNAME ] ; then exit ; fi 
        task add project\:$PRJNAME $TAGNAME $TSKNAME 1>/dev/null
    echo -e "\e[0;m"
done

答案3

正如@Sardathrion 在評論中指出的那樣,這看起來像這樣:

for i in "task 1" "task 2" "task 3"; do task add "$i"; done

答案4

希望這可以幫助某人,您可以用於task import這樣的用例。來自task的手冊頁:

       task import [<file> ...]
              Imports tasks in the JSON format.  Can be used to add new tasks, or update existing ones.  Tasks are identified by their UUID.

              If no file or "-" is specified, import tasks from STDIN.

              Setting rc.recurrence.confirmation to an appropriate level is recommended if import is to be used in automated workflows.  See taskrc(5).

              For importing other file formats, the standard task release comes with a few example scripts, such as:

                import-todo.sh.pl
                import-yaml.pl

所以,你可以這樣:

$ echo '[{"description":"task1"},{"description":"task2"}]' |task import -
Importing 'STDIN'
 add  bfc337ce-b446-453d-8cfe-c570bc1b5f03 task1
 add  556a737c-11f3-4a21-a872-67e56b75cdc4 task2
Imported 2 tasks.

當然,您可以根據需要添加任何屬性(標籤、項目、UDA 等)。 JSON 架構可在此處取得:https://taskwarrior.org/docs/design/task.html

要大量新增任務,您可以先建立一個包含所有資訊的文件,然後將其提供給task,或僅使用 Vim任務維基:)

相關內容