它对我有用。你确定你.zshrc的osx插件加载了吗?使用以下命令检查函数是否存在:
$ type tab
tab is a shell function
Run Code Online (Sandbox Code Playgroud)
然后,在您的终端中,只需运行命令
tab
Run Code Online (Sandbox Code Playgroud)
这将在插件定义的tab()函数中执行适当的行osx。如果它适用于 Terminal.app,它也应该适用于 iTerm2。
为了将此命令映射到自定义键盘快捷键,如CmdShiftR,请执行以下操作。打开 Automator.app 并创建一个新的Service。将其设置为从iTerm.app接收No Input,然后将Run AppleScript从左侧拖到编辑窗格中。
tell application "iTerm"
tell current terminal
tell current session
write text "tab"
end tell
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
那应该是这样的:

使用 zsh或类似工具将其保存在Open new Tab下。现在,在System Preferences » Keyboard » Keyboard Shortcuts下的Services下,分配一个键盘快捷键。
请注意,并非所有键盘快捷键都可用,您不能直接覆盖,CmdT因为这是一个内置快捷键。
