如何在Mac OS Lion的终端上通过在每个选项卡上执行一些命令来自动打开多个选项卡? [英] How can I open multiple tabs automatically on terminal in mac os Lion by executing some commands on each tab?
问题描述
我需要自动打开带有多个选项卡的终端,并需要在其上执行多个命令.
I need to automatically open terminal with multiple tabs and need to execute multiple commands on it.
我知道如何在Ubuntu中做到这一点.但它不适用于Mac OS.有想法吗?
I know how to do it in ubuntu. but its not working on mac os . Any Idea?
gnome-terminal --tab -e "tail -f somefile" --tab -e "some_other_command"
推荐答案
我可以给你一个提示.
使用osascript
,您可以做到.
更新:
您需要了解的一件事是,gnome-terminal
用于Linux. Gnome
是为Linux编写的非常流行的桌面环境.
One thing you need to understand is, gnome-terminal
is for Linux. Gnome
is a very popular Desktop environment written for Linux.
使用此oneliner打开以$ PWD作为工作目录的新选项卡:
Use this oneliner for opening a new tab with $PWD as the working directory:
osascript -e "tell application \"Terminal\"" -e "tell application \"System Events\" to keystroke \"t\" using {command down}" -e "do script \"cd $PWD; clear\" in front window" -e "end tell" > /dev/null
跟随一个班轮将只打开一个以$PWD
作为工作目录的新选项卡,并将执行echo Hi
Following one liner will just open a new tab with $PWD
as working directory and will execute echo Hi
osascript -e "tell application \"Terminal\"" -e "tell application \"System Events\" to keystroke \"t\" using {command down}" -e "do script \"cd $PWD; echo HI\" in front window" -e "end tell" > /dev/null
这篇关于如何在Mac OS Lion的终端上通过在每个选项卡上执行一些命令来自动打开多个选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!