-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_ftag
158 lines (145 loc) · 4.91 KB
/
_ftag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#compdef ftag
setopt localoptions warncreateglobal typesetsilent extendedglob
autoload -U is-at-least
typeset -a _arg_opts
if is-at-least 5.2; then
_arg_opts=(-s -S -C)
else
_arg_opts=(-s -C)
fi
local -a gtags=(${${(@f)"$(tag --usage)"}//(#m)*/${${(s: :)${MATCH}//[[:space:]]##/ }[2]}})
local -a ltags=( ${(@u)${(@s:,:)${(@f)"$(tag -Nl)"}}} )
# local state
integer ret=1
local context curcontext="$curcontext" state line
typeset -a arguments
# _files -W ~
arguments=(
'*--wutag[Also tag files with wutag]'
'*-w[Also tag files with wutag]'
'*--verbose[Display verbose messages when using ftag as a tag wrapper]'
'*-v[Display verbose messages when using ftag as a tag wrapper]'
'--font[Choose figlet font]:choose a figlet font:->figlet_fonts'
'-f[Choose figlet font]:choose a figlet font:->figlet_fonts'
'--wrapper[Use ftag as a wrapper to color output of tag]:wrapper commands:->tag'
'-W[Use ftag as a wrapper to color output of tag]:wrapper commands:->tag'
# ':*:message:action'
'--color[Specify no more than 3 colors for the output]:-- Choose colors --:->_colors'
'-C[Specify no more than 3 colors for the output]:== Choose colors ==:->_colors'
'--config[Specify location of configuration file]:config file:_files'
'-c[Specify location of configuration file]:config file:_files'
{-q,--query}'[Start fzf with a query]: :->query'
{-h,--help}'[Display a help message]'
{-b,--boxes}'[Add a box aroud header with boxes]'
{-T,--lolcat}'[Color to header with lolcat]'
{-t,--toilet}'[Color and format header with toilet]'
{-p,--path}'[Open in a directory]:Paths:_files'
{-l,--local}'[Use tags in local directory]: :->local_tags'
{-z,--zoxide}'[Start zoxide to select directory to use tags]'
{-j,--jump}'[Start autojump to select directory to use tags]'
{-n,--nocolor}'[Do not use color when displaying tags]'
{-N,--nofzf}'[Do not use fzf. This has limited functionality; pretty much for pretty-printing]'
{-s,--sort}'[Sort tags ascending or descending]:== Sort output ==:((d\:descending desc\:descending ++\:descending a\:ascending asc\:ascending +\:ascending))'
{-W,--wrapper}'[Use ftag as a wrapper to tag to have colored output]'
{-x,--xtrace}'[Extremely verbose output to help with debugging]'
{-d,--dump}'[Dump configuration variables]:== Dump config ==:((p\:"pipe to pager" pager\:"pipe to pager"))'
)
_arguments "${_arg_opts[@]}" $arguments \
&& ret=0
# '*: :->tags'
case $state in
query)
_alternative \
'ltags:-- Local Tags --:compadd -a - ltags' \
'gtags:-- Global Tags --:compadd -a - gtags' && \
ret=0
;;
local_tags)
_describe -t ltags '== Local Tags ==' ltags && \
ret=0
;;
figlet_fonts)
local expl
_wanted figlet_fonts expl "== Font ==" compadd \
${(@f)"$(_call_program figlet_fonts figlist)"} && \
ret=0
;;
_colors)
local -a colors=(
red bred brred green bgreen brgreen
yell byell bryell blue bblue brblue
magen bmagen brmagen cyan bcyan brcyan
)
_describe -t colors '== Colors ==' colors && \
ret=0
;;
tag)
# _wanted -V recent-dirs expl 'recent directory' compadd -S '' -Q -a values
$_comps[tag] "$@" && \
ret=0
;;
*)
_alternative \
'ltags:== Local Tags ==:compadd -a - ltags' \
'gtags:== Global Tags ==:compadd -a - gtags' && \
ret=0
;;
esac
return $ret
# case $state in
# args)
# curcontext="${curcontext%:*}-${words[2]}:"
#
# local lastarg=${words[${#words}]}
# local recipe
#
# local cmds; cmds=(
# ${(@f)$(_call_program figlet_fonts figlist)}
# )
# for ((i = 2; i < $#words; i++ )) do
# if [[ ${cmds[(I)${words[i]}]} -gt 0 ]]; then
# recipe=${words[i]}
# break
# fi
# done
#
# if [[ $lastarg = */* ]]; then
# # Arguments contain slash would be recognised as a file
# _arguments -s -S $arguments '*:: :_files'
# elif [[ $lastarg = *=* ]]; then
# # Arguments contain equal would be recognised as a variable
# _message "value"
# elif [[ $recipe ]]; then
# # Show usage message
# _message "`ftag --help`"
# # Or complete with other commands
# #_arguments -s -S $arguments '*:: :_just_commands'
# else
# _arguments -s -S $arguments '*:: :_ftag_tags'
# fi
# ;;
# esac
#
# return $ret
#
# (( $+functions[_ftag_tags] )) ||
# _ftag_tags() {
# [[ $PREFIX = -* ]] && return 1
# integer ret=1
# local -a global_tags; global_tags=(
# ${${(@f)"$(tag --usage)"}//(#m)*/${${(s: :)${MATCH}//[[:space:]]##/ }[2]}}
# )
# local -a local_tags; local_tags=(
# ${(@u)${(@s:,:)${(@f)"$(tag -Nl)"}}}
# )
#
# if compset -P '*='; then
# case "${${words[-1]%=*}#*=}" in
# *) _message 'value' && ret=0 ;;
# esac
# else
# _describe -t global_tags 'global tags' global_tags -qS "=" && ret=0
# _describe -t local_tags 'local tags' local_tags "$@"
# fi
#
# }