Create inbox todo.txt addon
This commit is contained in:
parent
317555179f
commit
1e7adfa51c
2 changed files with 79 additions and 1 deletions
79
.todo.actions.d/inbox
Executable file
79
.todo.actions.d/inbox
Executable file
|
@ -0,0 +1,79 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## Inbox todos storage file ##
|
||||||
|
export INBOX_PATH="$TODO_DIR"
|
||||||
|
export INBOX_FILE="inbox.txt"
|
||||||
|
export INBOX_FULL_PATH="$INBOX_PATH/$INBOX_FILE"
|
||||||
|
#export INBOX_THRESHOLD="14d"
|
||||||
|
|
||||||
|
## Display usage information ##
|
||||||
|
function usage {
|
||||||
|
cat <<-END
|
||||||
|
|
||||||
|
inbox - Create and manage your inbox tasks
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
inbox ls
|
||||||
|
List todos in $INBOX_FILE
|
||||||
|
|
||||||
|
inbox move ITEM#
|
||||||
|
Move specified todo out of $INBOX_FILE
|
||||||
|
|
||||||
|
inbox add DESCRIPTION
|
||||||
|
Add new todo to $INBOX_FILE
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
## Lists todos in stale.txt ##
|
||||||
|
function listInboxTodos {
|
||||||
|
$TODO_FULL_SH listfile "$INBOX_FULL_PATH"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
## Moves todo from inbox.txt to todo.txt ##
|
||||||
|
function moveTodo {
|
||||||
|
itemnum="$1"
|
||||||
|
getTodo "$itemnum" "$INBOX_FULL_PATH"
|
||||||
|
cleanTodo=$(echo "$todo" | sed -E 's/x [0-9]{4}-[0-9]{2}-[0-9]{2} //')
|
||||||
|
$TODO_FULL_SH add "$cleanTodo"
|
||||||
|
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||||
|
# delete line (changes line numbers)
|
||||||
|
sed -i.bak -e "${itemnum}s/^.*//" -e '/./!d' "$INBOX_FULL_PATH"
|
||||||
|
else
|
||||||
|
# leave blank line behind (preserves line numbers)
|
||||||
|
sed -i.bak -e "${itemnum}s/^.*//" "$INBOX_FULL_PATH"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
## Add todo to inbox.txt ##
|
||||||
|
function addTodo {
|
||||||
|
description="$1"
|
||||||
|
$TODO_FULL_SH addto inbox.txt "$description"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ "$1" = "usage" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "ls" ]; then
|
||||||
|
listInboxTodos
|
||||||
|
elif [ "$1" = "move" ] && [[ "$2" =~ [0-9]+ ]]; then
|
||||||
|
moveTodo "$2"
|
||||||
|
elif [ "$1" = "add" ] && [[ -n "$2" ]]; then
|
||||||
|
addTodo "$2"
|
||||||
|
else
|
||||||
|
cat <<-EndShortUsage
|
||||||
|
$TODO_SH inbox ls | List inbox tasks
|
||||||
|
$TODO_SH inbox move ITEM# | Move item from $INBOX_FILE to todo.txt
|
||||||
|
$TODO_SH inbox add DESCRIPTION | Add todo to $INBOX_FILE
|
||||||
|
EndShortUsage
|
||||||
|
fi
|
1
.zshrc
1
.zshrc
|
@ -20,7 +20,6 @@ SAVEHIST=10000
|
||||||
alias lss="ls -lah"
|
alias lss="ls -lah"
|
||||||
alias yt-dlp-mp4="yt-dlp --no-config --format 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4]'"
|
alias yt-dlp-mp4="yt-dlp --no-config --format 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4]'"
|
||||||
alias t="todo.sh"
|
alias t="todo.sh"
|
||||||
alias ti="todo.sh addto inbox.txt"
|
|
||||||
|
|
||||||
alias gco="git checkout"
|
alias gco="git checkout"
|
||||||
alias gcm="git commit -m"
|
alias gcm="git commit -m"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue