我有改变终端标题的功能。我希望将其传递给osascript命令。
我试着:
function title {
name=hostname
printf "\033]0;$name %s\007" "$1"
}
osascript -e "tell application \"Terminal\"" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"title newTitle \" in front window" \
-e "end tell"
> /dev/null;它不起作用。
有什么想法吗?
谢谢
发布于 2013-10-15 03:16:00
你的函数是在.bash_profile中定义的吗?如果是这样,这应该是可行的(如下所示)。如果没有,您需要添加它,否则您创建的新选项卡不知道该函数。
没有$1替换的多行脚本可以放在单引号中,而不需要转义...
osascript -e 'tell application "Terminal"
tell application "System Events" to keystroke "t" using {command down}
do script "title NewTitle" in front window
end tell'由于在启动新选项卡时生成的文本,> /dev/null似乎没有多大区别。
https://stackoverflow.com/questions/19366274
复制相似问题