task | reformatted with nixfmt
This commit is contained in:
parent
e3fea64660
commit
c3a0a0847f
119 changed files with 1010 additions and 2135 deletions
|
|
@ -1,4 +1,4 @@
|
|||
{pkgs, ...}: {
|
||||
{ pkgs, ... }: {
|
||||
home.file = {
|
||||
doascomplete = {
|
||||
enable = true;
|
||||
|
|
@ -10,36 +10,36 @@
|
|||
_init_completion -s || return
|
||||
|
||||
local i mode=normal
|
||||
[[ ''$1 == *doasedit ]] && mode=edit
|
||||
[[ $1 == *doasedit ]] && mode=edit
|
||||
|
||||
[[ ''$mode == normal ]] &&
|
||||
[[ $mode == normal ]] &&
|
||||
for ((i = 1; i <= cword; i++)); do
|
||||
if [[ ''${words[i]} != -* ]]; then
|
||||
local PATH=''$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
||||
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
||||
local root_command=''${words[i]}
|
||||
_command_offset ''$i
|
||||
_command_offset $i
|
||||
return
|
||||
fi
|
||||
[[ ''${words[i]} == -@(!(-*)[uUgCp]) ]] &&
|
||||
((i++))
|
||||
done
|
||||
|
||||
case "''$prev" in
|
||||
case "$prev" in
|
||||
-u)
|
||||
COMPREPLY=(''$(compgen -u -- "''$cur"))
|
||||
COMPREPLY=($(compgen -u -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
''$split && return
|
||||
$split && return
|
||||
|
||||
if [[ ''$cur == -* ]]; then
|
||||
local opts=''$(_parse_help "''$1")
|
||||
COMPREPLY=(''$(compgen -W ' ''${opts:-''$(_parse_usage "''$1")}' -- "''$cur"))
|
||||
if [[ $cur == -* ]]; then
|
||||
local opts=$(_parse_help "$1")
|
||||
COMPREPLY=($(compgen -W ' ''${opts:-$(_parse_usage "$1")}' -- "$cur"))
|
||||
[[ ''${COMPREPLY-} == *= ]] && compopt -o nospace
|
||||
return
|
||||
fi
|
||||
if [[ ''$mode == edit ]]; then
|
||||
if [[ $mode == edit ]]; then
|
||||
_filedir
|
||||
fi
|
||||
} &&
|
||||
|
|
@ -105,26 +105,26 @@
|
|||
taskcommand='task rc.verbose:nothing rc.confirmation:no rc.hooks:off'
|
||||
|
||||
_task_get_tags() {
|
||||
''$taskcommand _tags
|
||||
$taskcommand _tags
|
||||
}
|
||||
|
||||
_task_get_config() {
|
||||
''$taskcommand _config
|
||||
$taskcommand _config
|
||||
}
|
||||
|
||||
_task_offer_priorities() {
|
||||
COMPREPLY=( ''$(compgen -W "L M H" -- ''${cur/*:/}) )
|
||||
COMPREPLY=( $(compgen -W "L M H" -- ''${cur/*:/}) )
|
||||
}
|
||||
|
||||
_task_offer_projects() {
|
||||
COMPREPLY=( ''$(compgen -W "''$(''$taskcommand _projects)" -- ''${cur/*:/}) )
|
||||
COMPREPLY=( $(compgen -W "$($taskcommand _projects)" -- ''${cur/*:/}) )
|
||||
}
|
||||
|
||||
_task_offer_contexts() {
|
||||
COMPREPLY=( ''$(compgen -W "''$(''$taskcommand _context) define delete list none show" -- ''$cur) )
|
||||
COMPREPLY=( $(compgen -W "$($taskcommand _context) define delete list none show" -- $cur) )
|
||||
}
|
||||
|
||||
_task_context_alias=''$(''$taskcommand show | grep alias.*context | cut -d' ' -f1 | cut -d. -f2)
|
||||
_task_context_alias=$($taskcommand show | grep alias.*context | cut -d' ' -f1 | cut -d. -f2)
|
||||
|
||||
_task()
|
||||
{
|
||||
|
|
@ -144,25 +144,25 @@
|
|||
# echo "prev='''$prev'"
|
||||
# echo "prev2='''$prev2'"
|
||||
|
||||
abbrev_min=''$(''$taskcommand show | grep "abbreviation.minimum" | awk {'print ''$2'})
|
||||
commands_aliases=''$(echo ''$(''$taskcommand _commands; ''$taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ")
|
||||
opts="''$commands_aliases ''$(''$taskcommand _columns)"
|
||||
abbrev_min=$($taskcommand show | grep "abbreviation.minimum" | awk {'print $2'})
|
||||
commands_aliases=$(echo $($taskcommand _commands; $taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ")
|
||||
opts="$commands_aliases $($taskcommand _columns)"
|
||||
|
||||
case "''${prev}" in
|
||||
''$_task_context_alias|cont|conte|contex|context)
|
||||
$_task_context_alias|cont|conte|contex|context)
|
||||
_task_offer_contexts
|
||||
return 0
|
||||
;;
|
||||
:)
|
||||
case "''${prev2}" in
|
||||
pri|prior|priori|priorit|priority)
|
||||
if [ ''${#prev2} -ge ''$abbrev_min ]; then
|
||||
if [ ''${#prev2} -ge $abbrev_min ]; then
|
||||
_task_offer_priorities
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
pro|proj|proje|projec|project)
|
||||
if [ ''${#prev2} -ge ''$abbrev_min ]; then
|
||||
if [ ''${#prev2} -ge $abbrev_min ]; then
|
||||
_task_offer_projects
|
||||
fi
|
||||
return 0
|
||||
|
|
@ -187,13 +187,13 @@
|
|||
:)
|
||||
case "''${prev}" in
|
||||
pri|prior|priori|priorit|priority)
|
||||
if [ ''${#prev} -ge ''$abbrev_min ]; then
|
||||
if [ ''${#prev} -ge $abbrev_min ]; then
|
||||
_task_offer_priorities
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
pro|proj|proje|projec|project)
|
||||
if [ ''${#prev} -ge ''$abbrev_min ]; then
|
||||
if [ ''${#prev} -ge $abbrev_min ]; then
|
||||
_task_offer_projects
|
||||
fi
|
||||
return 0
|
||||
|
|
@ -212,24 +212,24 @@
|
|||
esac
|
||||
;;
|
||||
+*)
|
||||
local tags=''$(_task_get_tags | sed 's/^/+/')
|
||||
COMPREPLY=( ''$(compgen -W "''${tags}" -- ''${cur}) )
|
||||
local tags=$(_task_get_tags | sed 's/^/+/')
|
||||
COMPREPLY=( $(compgen -W "''${tags}" -- ''${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-*)
|
||||
local tags=''$(_task_get_tags | sed 's/^/-/')
|
||||
COMPREPLY=( ''$(compgen -W "''${tags}" -- ''${cur}) )
|
||||
local tags=$(_task_get_tags | sed 's/^/-/')
|
||||
COMPREPLY=( $(compgen -W "''${tags}" -- ''${cur}) )
|
||||
return 0
|
||||
;;
|
||||
rc.*)
|
||||
local config=''$(_task_get_config | sed -e 's/^/rc\./' -e 's/''$/:/')
|
||||
COMPREPLY=( ''$(compgen -W "''${config}" -- ''${cur}) )
|
||||
local config=$(_task_get_config | sed -e 's/^/rc\./' -e 's/$/:/')
|
||||
COMPREPLY=( $(compgen -W "''${config}" -- ''${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
case "''${prev}" in
|
||||
import)
|
||||
COMPREPLY=( ''$(compgen -o "default" -- ''${cur}) )
|
||||
COMPREPLY=( $(compgen -o "default" -- ''${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
|
@ -238,7 +238,7 @@
|
|||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( ''$(compgen -W "''${opts}" -- ''${cur}) )
|
||||
COMPREPLY=( $(compgen -W "''${opts}" -- ''${cur}) )
|
||||
return 0
|
||||
}
|
||||
complete -o nospace -F _task task
|
||||
|
|
@ -272,7 +272,7 @@
|
|||
|
||||
function __get_help_items()
|
||||
{
|
||||
echo -e "''$( __get_commands ) interval hints date duration dom"
|
||||
echo -e "$( __get_commands ) interval hints date duration dom"
|
||||
}
|
||||
|
||||
function __get_options()
|
||||
|
|
@ -283,7 +283,7 @@
|
|||
function __get_ids()
|
||||
{
|
||||
local count
|
||||
count="''$( timew get dom.tracked.count )"
|
||||
count="$( timew get dom.tracked.count )"
|
||||
if [[ "''${count}" -eq "0" ]] ; then
|
||||
echo ""
|
||||
else
|
||||
|
|
@ -293,12 +293,12 @@
|
|||
|
||||
function __get_tags()
|
||||
{
|
||||
timew tags | tail -n +4 -- | sed -e "s|[[:space:]]*-''$||"
|
||||
timew tags | tail -n +4 -- | sed -e "s|[[:space:]]*-$||"
|
||||
}
|
||||
|
||||
function __get_extensions()
|
||||
{
|
||||
timew extensions | awk '{if(NR>6)print ''$1}'
|
||||
timew extensions | awk '{if(NR>6)print $1}'
|
||||
}
|
||||
|
||||
function __has_entered_id()
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
|
||||
function __has_entered_subcommand()
|
||||
{
|
||||
local subcommands=''$( __get_subcommands "''${1}" )
|
||||
local subcommands=$( __get_subcommands "''${1}" )
|
||||
|
||||
for word in "''${COMP_WORDS[@]}" ; do
|
||||
for cmd in ''${subcommands} ; do
|
||||
|
|
@ -329,7 +329,7 @@
|
|||
|
||||
function __has_entered_help_item()
|
||||
{
|
||||
local items=''$( __get_help_items )
|
||||
local items=$( __get_help_items )
|
||||
|
||||
for word in "''${COMP_WORDS[@]:2}" ; do
|
||||
for item in ''${items} ; do
|
||||
|
|
@ -358,17 +358,17 @@
|
|||
local line wordlist
|
||||
|
||||
declare -a wordlist
|
||||
while IFS=''$'\n' read -r line ; do
|
||||
while IFS=$'\n' read -r line ; do
|
||||
wordlist+=( "''${line}" )
|
||||
done <<< "''$( __get_tags )"
|
||||
done <<< "$( __get_tags )"
|
||||
|
||||
declare -a completions
|
||||
while read -r line ; do
|
||||
completions+=( "''${line}" )
|
||||
done < <( compgen -W "''$(printf '%q ' "''${wordlist[@]}")" -- "''${cur}" 2>/dev/null )
|
||||
done < <( compgen -W "$(printf '%q ' "''${wordlist[@]}")" -- "''${cur}" 2>/dev/null )
|
||||
|
||||
for completion in "''${completions[@]}" ; do
|
||||
COMPREPLY+=( "''$(printf "%q" "''${completion}")" )
|
||||
COMPREPLY+=( "$(printf "%q" "''${completion}")" )
|
||||
done
|
||||
}
|
||||
|
||||
|
|
@ -385,7 +385,7 @@
|
|||
wordlist=""
|
||||
;;
|
||||
annotate|continue|delete|join|lengthen|move|resize|shorten|split)
|
||||
wordlist=''$( __get_ids )
|
||||
wordlist=$( __get_ids )
|
||||
;;
|
||||
export|gaps|start|stop|summary|tags|track)
|
||||
__complete_tag
|
||||
|
|
@ -393,40 +393,40 @@
|
|||
;;
|
||||
modify)
|
||||
if __has_entered_subcommand "''${first}" ; then
|
||||
wordlist=''$( __get_ids )
|
||||
wordlist=$( __get_ids )
|
||||
else
|
||||
wordlist=''$( __get_subcommands "''${first}" )
|
||||
wordlist=$( __get_subcommands "''${first}" )
|
||||
fi
|
||||
;;
|
||||
tag|untag)
|
||||
if __is_entering_id ; then
|
||||
wordlist=''$( __get_ids )
|
||||
wordlist=$( __get_ids )
|
||||
elif __has_entered_id ; then
|
||||
__complete_tag
|
||||
return
|
||||
else
|
||||
wordlist=''$( __get_ids )
|
||||
wordlist=$( __get_ids )
|
||||
fi
|
||||
;;
|
||||
report)
|
||||
wordlist=''$( __get_extensions )
|
||||
wordlist=$( __get_extensions )
|
||||
;;
|
||||
help)
|
||||
if __has_entered_help_item ; then
|
||||
wordlist=""
|
||||
else
|
||||
wordlist=''$( __get_help_items )
|
||||
wordlist=$( __get_help_items )
|
||||
fi
|
||||
;;
|
||||
-*)
|
||||
wordlist=''$( __get_options )
|
||||
wordlist=$( __get_options )
|
||||
;;
|
||||
*)
|
||||
wordlist=''$( __get_commands )
|
||||
wordlist=$( __get_commands )
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=(''$( compgen -W "''${wordlist}" -- "''${cur}" ))
|
||||
COMPREPLY=($( compgen -W "''${wordlist}" -- "''${cur}" ))
|
||||
}
|
||||
|
||||
complete -F _timew timew
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue