当 iTerm 启动时如何运行命令?

发布于 2024-07-13 23:03:53 字数 396 浏览 6 评论 0原文

我正在为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终陌 2024-07-20 23:03:53

您遇到这个问题是因为您的脚本运行然后终止。 您所需要做的就是在脚本末尾添加一个read或同样复杂的内容来表示“按任意键完成脚本并关闭窗口......”。

更新

我写了这个测试脚本:

$ cat echoscript 
#!/bin/bash
echo "Hello world"
read text
$ 

我创建了一个书签,这样:

name: test
command: /Users/chasrmartin/echoscript
Working directory: /Users/chasrmartin

当我打开书签 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:

$ cat echoscript 
#!/bin/bash
echo "Hello world"
read text
$ 

I created a bookmark so:

name: test
command: /Users/chasrmartin/echoscript
Working directory: /Users/chasrmartin

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文