我正在使用Iterm2版本Build 3.0.4。
我想从命令行(在bash中)创建别名以打开新标签页。
我尝试了这段代码:
function tab () {
osascript &>/dev/null <<EOF
activate application "iTerm"
tell application "System Events" to keystroke "t" using command down
tell application "iTerm" to tell session -1 of current terminal to write text "pwd"
EOF
}
但它不能正常工作。有人能解决这个问题吗(或使用更新版本)?
pwd
的代码没有起作用。请将tell newSplit
替换为tell second session of current tab of current window
,参考此答案。您还可以删除_split horizontally_命令中的set newSplit to
部分。要拆分当前会话(而不是创建新标签),请删除整个_create tab_行。 - Tobias Geislerttab
可以被编译,并且是一个非常简单的选项。 - xverges