github.com/grantbow/fit@v0.7.1-0.20220916164603-1f7c88ac81e6/hooks/_bug (about) 1 #compdef bug 2 # This script defines zsh autocompletion for the bug distributed 3 # bug tracker available at https://github.com/driusan/bug 4 # 5 # To use it, put it somewhere in your fpath 6 # 7 # ie. in your .zshrc add "fpath=(~/.bug $fpath)" and then 8 # put this file in ~/.bug 9 10 __bug_get_bugs() { 11 local issues 12 # call bug list and pipe it to sed to convert it to 13 # issuenumber:description format, so that we can 14 # pass it to _describe for autocompletion with the 15 # bug title as a hint 16 issues=(${(f)"$(_call_program commands bug list | sed 's/^Issue \([0-9]\)*: \(.*\)/\1:\2/')"}) 17 _describe 'Issues' issues 18 } 19 20 # These all tag issue numbers as the first parameter, so just 21 # use __bug_get_bugs 22 _bug_list() { 23 __bug_get_bugs 24 _arguments '2:Arguments:((--tags:"Include tag list in output"))' 25 } 26 _bug_edit () { 27 if ((CURRENT == 3)); then 28 __bug_get_bugs 29 fi 30 } 31 _bug_tag() { 32 __bug_get_bugs 33 } 34 _bug_relabel () { 35 __bug_get_bugs 36 } 37 _bug_close() { 38 __bug_get_bugs 39 } 40 _bug_status() { 41 __bug_get_bugs 42 } 43 _bug_priority() { 44 __bug_get_bugs 45 } 46 _bug_milestone() { 47 __bug_get_bugs 48 } 49 50 # Help can take a command as a parameter to, so add them to 51 # the list of completion suggestions 52 _bug_help() { 53 compadd create list edit tag relabel close status priority milestone env pwd roadmap version help 54 } 55 56 _bug() { 57 if (( CURRENT > 2)); then 58 _call_function 1 _bug_$words[2] 59 else 60 compadd create list edit tag relabel close status priority milestone env pwd roadmap version help 61 fi 62 63 } 64 65 #_bug