基于默认参数的函数的自定义zsh补全 [英] Custom zsh completion for a function based on default arguments

查看:120
本文介绍了基于默认参数的函数的自定义zsh补全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何基于现有的完成定义和默认参数设置函数的完成.

How can I setup completion for a function, based on existing completion definitions and default arguments.

一个简化的示例(可以重写为别名):

A simplified example (which could be rewritten as an alias):

gpl() {
    git pull origin $@
}

此操作应与git pull origin之后的操作相同.

This should have the same completion as after git pull origin.

推荐答案

compdef -e 'words[1]=(git pull origin); service=git; (( CURRENT+=2 )); _git' ggl

这将对完成系统使用的$words$service$CURRENT var进行按摩,然后调用_git完成函数.

This massages the $words, $service and $CURRENT vars used by the completion system, and then calls the _git completion function.

(感谢#zsh上的Mikachu).

(Thanks to Mikachu on #zsh).

这篇关于基于默认参数的函数的自定义zsh补全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆