每当./myscript.sh启动时如何触发终端全屏

时间:2017-07-10 20:49:27

标签: bash macos terminal

我正在编写一个bash脚本,它在OS X提供的Terminal.app中运行一些进程,因此与它的交互基本上来自于终端本身的用户。

每当我们$ ./myScript.sh我需要终端进入全屏。 如果有人可以给我一些bash脚本的例子来触发全屏幕,当它被称为真棒... 任何想法? : - )

2 个答案:

答案 0 :(得分:2)

尝试在您的脚本中添加此行:

osascript -e 'tell application "System events" to keystroke "f" using {command down, control down}'

它切换“全屏模式”,以便您可以在最后再次使用它以再次退出“全屏模式”

与输入 + Ctrl + F相同。

如果您无法弄清楚如何编辑原始脚本,或者您不想这样做,可以像这样放置一个包装器。

#!/bin/bash

# Toggle full screen
osascript -e 'tell application "System events" to keystroke "f" using {command down, control down}'

./YourOriginalScript "$@"

# Toggle full screen
osascript -e 'tell application "System events" to keystroke "f" using {command down, control down}'

将上述内容保存为wrapper,并将其设为可执行文件:

chmod +x wrapper

然后使用包装器运行脚本,如下所示:

./wrapper

答案 1 :(得分:-1)

您可能需要安装 xdotool cliclick

安装后添加到您的脚本:

xdotool key Ctrl+Cmd+F

cliclick ku:ctrl,cmd,f