zsh - Zshell 完成调用另一个函数
问题描述
我为 tmux 编写了几个 zsh 函数。我正在尝试为其中一些功能添加自动完成功能,但遇到了麻烦。
其中一个功能tk
是tmux kill-session
. 此函数采用要终止的会话的名称,如果未提供,则回退到当前会话。
这是我的函数的样子:
function tk {
if [ $# -ne 0 ]; then
tmux kill-session -t $1
else
tmux kill-session
fi
}
我还编写了一个active_tmux_sessions
在其他一些地方使用的函数:
function active_tmux_sessions {
tmux ls -F "#{session_name}" 2>/dev/null | cut -d: -f1
}
这是我将它们粘合在一起的方法。
function _tk() {
compadd $(active_tmux_sesions)
}
compdef _tk tk
当我键入tk <tab>
时,我收到此错误:
tk _tk:1: command not found: active_tmux_sesions
_tk:1: command not found: active_tmux_sesions
_tk:1: command not found: active_tmux_sesions
解决方案
推荐阅读
- wso2 - SourceHandler Writer 调用informWriterError 时为null,无法工作
- java - Project Reactor,在创建 lambda 之外使用 Flux sink
- excel - 我想在不使用 sendkeys 的情况下自动化 F2+Enter。我从单词表中提取的文本没有任何作用
- solr - 使用版本号更新 SOLR 模式
- java - 如何使用 JAVA Apache httpclient 通过 rest api 更新共享点文档的元数据?
- sql - 重命名文件源
- flutter - 颤振等效于 layout_gravity="bottom"
- sql - 通过查找顺序递归查询排序
- android - 有什么方法可以传输数据说在 inappbrowser 中定义的变量并在 executeScript 方法中传递它的值?
- c# - 尝试使用 cmsImport 从逗号分隔的字符串导入到 MultipleTextstring