Timewarrior: New move function
This commit is contained in:
parent
c37b5ae6df
commit
9ddd370b4a
70
zshrc
70
zshrc
|
@ -400,11 +400,11 @@ function load-gpg-agent() {
|
||||||
# Taskwarrior {{{
|
# Taskwarrior {{{
|
||||||
## Aliases
|
## Aliases
|
||||||
alias t="task"
|
alias t="task"
|
||||||
|
### Filter by tag
|
||||||
## By tag
|
|
||||||
alias tawork="task +work | head"
|
alias tawork="task +work | head"
|
||||||
alias taperso="task +perso | head"
|
alias taperso="task +perso | head"
|
||||||
|
|
||||||
|
## Functions
|
||||||
## search a task by it's name (case INsensitive) {{{
|
## search a task by it's name (case INsensitive) {{{
|
||||||
function tase() {
|
function tase() {
|
||||||
local search=""
|
local search=""
|
||||||
|
@ -420,12 +420,17 @@ function tasec() {
|
||||||
}
|
}
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
## Completion
|
## Completion {{{
|
||||||
zstyle ':completion:*:*:task:*' verbose yes
|
zstyle ':completion:*:*:task:*' verbose yes
|
||||||
zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'
|
zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'
|
||||||
zstyle ':completion:*:*:task:*' group-name ''
|
zstyle ':completion:*:*:task:*' group-name ''
|
||||||
|
## }}}
|
||||||
# }}}
|
# }}}
|
||||||
# Timewarrior {{{
|
# Timewarrior {{{
|
||||||
|
## Aliases
|
||||||
|
alias timv="timove"
|
||||||
|
|
||||||
|
## Functions
|
||||||
## Display tasks of today {{{
|
## Display tasks of today {{{
|
||||||
function tiday() {
|
function tiday() {
|
||||||
if [ "${#}" -eq 0 ]; then
|
if [ "${#}" -eq 0 ]; then
|
||||||
|
@ -581,6 +586,65 @@ function tirm() {
|
||||||
unset tirm_confirmation tirm_task_id
|
unset tirm_confirmation tirm_task_id
|
||||||
}
|
}
|
||||||
## }}}
|
## }}}
|
||||||
|
## Move a time tracking {{{
|
||||||
|
function timove() {
|
||||||
|
|
||||||
|
# Define new_start empty by default
|
||||||
|
timove_task_new_start=""
|
||||||
|
|
||||||
|
# Verify argument
|
||||||
|
case "${#}" in
|
||||||
|
1 )
|
||||||
|
## Get the first arg as task ID
|
||||||
|
timove_task_id="${1}"
|
||||||
|
;;
|
||||||
|
2 )
|
||||||
|
## Get the first arg as task ID
|
||||||
|
timove_task_id="${1}"
|
||||||
|
|
||||||
|
## Get the second arg as new start time for the task
|
||||||
|
timove_task_new_start="${2}"
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
## Ask the user to choose an ID in tasks from the yesterday {{{
|
||||||
|
timew summary from yesterday :ids || return 0
|
||||||
|
|
||||||
|
printf '%b' "Enter the ${MAGENTAB}ID${RESET} of the task to move : "
|
||||||
|
read -r timove_task_id
|
||||||
|
## }}}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# If no task with this ID exists in the last month, exit function {{{
|
||||||
|
if ! timew summary :month :ids | grep --quiet -- " @${timove_task_id} "; then
|
||||||
|
printf '%b' "No available task in the last month with ${REDB}${timove_task_id}${RESET} ID."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# Get task's description from all task of this month
|
||||||
|
local timove_task_desc=$(timew summary :month :ids | sed -n "s/.*@\(${timove_task_id} .*\)/\1/p" | sed 's/ */ − /g')
|
||||||
|
|
||||||
|
# Check or ask for new start time {{{
|
||||||
|
if [ -z "${timove_task_new_start}" ]; then
|
||||||
|
printf '%b' "Enter the ${MAGENTAB}new start time${RESET} (or new date 'YYYY-MM-DD${REDB}T${RESET}HH:MM:SS') for this task : "
|
||||||
|
read -r timove_task_new_start
|
||||||
|
fi
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
printf '%b' "Move \"${MAGENTAB}${timove_task_desc}${RESET}\" to ${REDB}=> ${timove_task_new_start} <=${RESET} [Y/n] ? "
|
||||||
|
read -r timove_confirmation
|
||||||
|
|
||||||
|
# Check confirmation
|
||||||
|
if printf -- '%s' "${timove_confirmation:=y}" | grep --quiet --word-regexp -- "y"; then
|
||||||
|
timew move @"${timove_task_id}" "${timove_task_new_start}" || return 0
|
||||||
|
printf '%b' "${timove_task_desc} was moved to ${timove_task_new_start}."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Unset defined variables
|
||||||
|
unset timove_confirmation timove_task_id timove_task_new_start
|
||||||
|
}
|
||||||
|
## }}}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue