Patch - completion scripts

From 950acdf2990269a6d054e9608a1fed1dddf020a0 Mon Sep 17 00:00:00 2001
From: Federico Hernandez <ultrafredde@gmail.com>
Date: Sun, 17 May 2009 22:34:28 +0200
Subject: [PATCH] Re-arranged shell completion scipts into more suitable directory structure.
This commit is contained in:
Paul Beckingham 2009-05-17 17:15:46 -04:00
parent 6bef54cdae
commit 32d89560d5
2 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,56 @@
#
# bash completion support for task 1.7.0-2
# Copyright (C) 2009 Federico Hernandez <ultrafredde@gmail.com>
# Distributed under the GNU General Public License, version 2.0
#
# The routines will do completion of:
#
# *) task subcommands
# *) local and remote tag names
#
# To use these routines:
#
# 1) Copy this file to somewhere (e.g. ~/.task-completion.sh).
# 2) Added the following line to your .bashrc:
# source ~/.task-completion.sh
#
# OR
#
# 3) Copy the file to /etc/bash_complettion.d
# 4) source /etc/bash_completion
#
# To submit patches/bug reports:
#
# *) Send them to the mailing list:
#
# taskprogram@googlegroups.com
#
# *) CC the all patchesi/bug reports to:
#
# Federico Hernandez <ultrafredde@gmail.com>
#
_task()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="active add annotate append calendar color completed delete done duplicate edit export ghistory help history import info list long ls newest next oldest overdue projects start stats stop summary tags timesheet undelete undo version"
case "${prev}" in
ls|list|long)
if [[ ${cur} == +* ]] ; then
local tags=$( task tags | egrep -v 'tags|^$'|sed 's/^/+/' )
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
return 0
fi
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _task task

34
scripts/zsh/_task Normal file
View file

@ -0,0 +1,34 @@
#compdef task
# zsh completion for task
# P.C. Shyamshankar
typeset -g _task_cmds
_task_cmds=($(task rubbish-command | sed -n -e 's/^\s\+task \(\w\+\) .*/\1/p' | grep -v ID))
# As of task 1.7.0,
# _task_cmds=(add append annotate completed edit duplicate delete undelete info start stop done undo projects tags summary timesheet history ghistory next calendar active overdue stats import export color version help list long ls newest oldest)
_task() {
_arguments -s -S \
"*::task command:_task_commands"
return 0
}
(( $+functions[_task_commands] )) ||
_task_commands() {
local cmd ret=1
if (( CURRENT == 1 )); then
_describe -t commands 'task command' _task_cmds
else
local curcontext="${curcontext}"
cmd="${_task_cmds[(r)$words[1]:*]%%:*}"
if (( $#cmd )); then
curcontext="${curcontext%:*:*}:task-${cmd}"
_call_function ret _task_${cmd} || _message "No command remaining."
else
_message "Unknown subcommand ${cmd}"
fi
return ret
fi
}