当 iTerm 启动时如何运行命令?
我正在为 Mac 配置 iTerm 终端模拟器来执行我想要的操作。 显然,一切都是通过他们所谓的“书签”完成的。 好的。 我正在尝试创建一个书签,该书签将打开一个选项卡、cd 到某个 Rails 项目,然后运行命令 script/server
。 应该发生的情况是,这将启动服务器守护进程(“Mongrel”),并且每次查看该选项卡时我都会看到输出滚动。
在配置对话框中,在“命令”下我放置了script/server
,在“工作目录”下我放置了项目目录。
发生的情况是该选项卡出现 1/10 秒然后消失。
回想起我在 Unix screen 命令中遇到的类似问题,我尝试输入 bash -c 'script/server' 的“命令”,但结果是相同的。
I'm working on configuring the iTerm terminal emulator for the Mac to do what I want. Apparently everything is done through what they call "bookmarks." OK, fine. I'm trying to create a bookmark that will open a tab, cd to a certain Rails project, and run the command script/server
. What's supposed to happen is that this will launch the server daemon ("Mongrel") and I'll see the output scrolling by every time I look at that tab.
In the config dialog, under "command" I put script/server
and under "working dir" I put the project directory.
What happens is that the tab appears for 1/10th of a second then vanishes.
Recalling a similar problem I had with the Unix screen command, I tried putting a "command" of bash -c 'script/server'
but the result was identical.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您遇到这个问题是因为您的脚本运行然后终止。 您所需要做的就是在脚本末尾添加一个
read
或同样复杂的内容来表示“按任意键完成脚本并关闭窗口......”。更新
我写了这个测试脚本:
我创建了一个书签,这样:
当我打开书签
test
时,我看到我的“Hello world”,它会等待我输入 return。 当我输入 return 时,它就消失了。You're running into that problem because your script runs and then terminates. All you need to do is put a
read
or something equally sophisticated to say "Press any key to complete script and close window...." at the end of the script.update
I wrote this test script:
I created a bookmark so:
When I open the bookmark
test
, I see my "Hello world", and it waits until I type return. When I type return, it goes away.