[英]tcsh completion: Suffix variables with =
I am working on a make completion in tcsh.我正在 tcsh 中完成 make 。 The desired completion for new words may be either make-targets or variables.
新词的理想补全可以是 make-targets 或变量。
For example:例如:
complete make 'n/*/(footarget1 bartarget2 FOOVAR1= BARVAR2=)/'
By writing it this way, a new space is suffixed after the completion which is not convenient when trying to set a VAR (have to delete the space).通过这样写,完成后会添加一个新的空格后缀,这在尝试设置 VAR 时不方便(必须删除空格)。
If I set the suffix to null it will not be convenient when completing a target (should type a space for next arguement).如果我将后缀设置为空,则在完成目标时将不方便(应该为下一个争论输入一个空格)。
Is there a way to suffix a space when one of the targets is completed but not suffix anything when a VAR is?有没有办法在其中一个目标完成时添加空格,但在 VAR 完成时不添加任何后缀?
It's simple, as long as all your targets can be separated from Variables by upper/lowercase.很简单,只要您的所有目标都可以通过大写/小写与变量分开。
complete make \
'C@B*@(BARVAR2=)@@' \
'C@F*@(FOOVAR1=)@@' \
'C@V*@(VAR1= VAR2=)@@' \
'n@*@(target1 target2 VAR1 VAR2 BARVAR2 FOOVAR1)@'
For completion, only the first (read from top to bottom) rule which fits is used.为了完成,仅使用适合的第一个(从上到下阅读)规则。
If you start with uppercase ' B
', then the first rule hits, completing to BARVAR2=
, ommitting the suffix space.如果您以大写的 '
B
' 开头,则第一个规则命中,完成到BARVAR2=
,省略后缀空格。
If you start with uppercase ' F
', FOOVAR1=
is completed similarly.如果您以大写字母 '
F
' FOOVAR1=
,则FOOVAR1=
的完成方式类似。
' V
' has two options, separated by spaces. '
V
' 有两个选项,用空格分隔。
You can add new variables by simply adding them in the parenthesis of their starting character.您可以通过简单地将新变量添加到其起始字符的括号中来添加新变量。 If you need other starting characters, simply duplicate the line
'C@B*@(BARVAR2=)@@' \\
and replace B*
with your character (eg G*
) in the newly generated line.如果您需要其他起始字符,只需在新生成的行中复制
'C@B*@(BARVAR2=)@@' \\
并将B*
替换为您的字符(例如G*
)。
If your input does not start with these uppercase characters, the last rule applies, completing to target1/target2.如果您的输入不是以这些大写字符开头,则应用最后一条规则,完成到 target1/target2。
These will be added with suffix space, if the match can be completed without ambiguity.如果匹配可以无歧义地完成,这些将添加后缀空格。
As a bonus, you could also put these as your first rules:作为奖励,您还可以将这些作为您的首要规则:
'c@B*=@(val1)@' \|
'c@F*=@(val2)@'
If your current word is BARVAR2=
, then this rule will give you val1
as completion.如果您当前的单词是
BARVAR2=
,那么此规则将为您提供val1
作为完成。
For FOOVAR1=
it gives val2
.对于
FOOVAR1=
它给出val2
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.