Skip to content

Instantly share code, notes, and snippets.

@matze
Created September 24, 2012 18:04
Show Gist options
  • Save matze/3777344 to your computer and use it in GitHub Desktop.
Save matze/3777344 to your computer and use it in GitHub Desktop.
TicGit bash completion, originally by Nick Anderson
# Author: Nick Anderson (http://www.cmdln.org)
# Contributions: Matthias Vogelgesang (http://bloerg.net)
# Description: Simple Bash Completion for ticgit
_ti()
{
local cur prev opts state_opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="assign checkout comment list new points recent show state sync tag"
state_opts="open resolved invalid hold"
case "${prev}" in
list)
local list_opts="--order --tag --state --assigned --saveas --list"
COMPREPLY=( $(compgen -W "${list_opts}" -- ${cur}) )
return 0
;;
ti)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
state | --state)
COMPREPLY=( $(compgen -W "${state_opts}" ${cur}) )
return 0
;;
new)
COMPREPLY="-t"
return 0
;;
show | checkout)
local tickets=$(ti list | tail -n +4 | awk '{ if ($1 != "*") print $1; }' | tr "\\n" " ")
COMPREPLY=( $(compgen -W "${tickets}" ${cur}) )
return 0
;;
*)
return 0
;;
esac
}
complete -F _ti ti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment