如何在 Mac OSX 上加速 Terminal.app 或 iTerm?

pma*_*ana 41 mac terminal iterm

每次我在几个小时内不使用 iTerm 或终端后启动它时,返回提示都需要 10-20 秒的时间。屏幕是空白的,虽然我可以输入但实际上无法运行任何命令。

如果我退出任一应用程序,后续启动(如果此后相对较快完成)都非常快。只有当应用程序没有运行几个小时时才会出现缓慢。

我在 MacBookPro 上运行 OSX 10.5.7。我在另一台计算机上有完全相同的设置,没有减速。

任何想法如何再次加快速度?

小智 40

尝试删除以下 Apple 系统日志文件/var/log/asl/

sudo rm /var/log/asl/*.asl
Run Code Online (Sandbox Code Playgroud)

这对我有用。

  • 正如 [OsXDaily](http://osxdaily.com/2010/05/06/speed-up-a-slow-terminal-by-clearing-log-files/) 所指出的,我建议使用 `sudo rm -rf /private/var/log/asl/*.asl` 因为它更安全,因为它 1) 只删除日志文件 2) 避免进入错误的目录并删除所有文件。 (7认同)
  • (ASL = Apple 系统日志) (3认同)
  • @JamesMcMahon `login` 进程似乎读取了 `/var/log/asl` 顶层的所有文件和文件夹。尝试运行`sudo opensnoop | grep /var/log/asl`。 (3认同)

小智 31

另一个提示可能会有所帮助:

将启动 shell 从默认更改/usr/bin/login/bin/bash -l,或者/usr/bin/zsh如果您使用 zsh。

这可能会使您的终端/iTerm2 以光速启动!

  • 对于终端:首选项→启动:从“默认登录shell”更改为“命令:/bin/bash -l

  • 对于 iTerm2:首选项 → 配置文件 → 常规 → 命令:从“登录外壳”更改为“命令:/bin/bash -l

  • 这大大加快了新标签的加载速度。 (2认同)

tma*_*sen 9

我是否需要一定的声誉才能对帖子发表评论?无论如何,清除系统日志也对我有用,谢谢。我曾尝试用此处的补丁修补 path_helper:gist.github.com/123525,如http://mjtsai.com/blog/2009/04/01/slow-opening-terminal-windows/上的评论中所建议的(在本线程前面引用)但无济于事。我收到一个神秘的错误。但是,该补丁应该会加快 terminal.app 的启动速度。

另外:正如我所提到的,清除日志对我来说很有效,但是随着我删除日志后日志不断变大,问题继续出现。我发现“调整” /etc/asl.conf 给了我一个更永久的解决方案。修改是只记录归类为“关键”或更关键的消息,而不是记录“通知”类别和比这更关键的消息。另外,我不理会来自 ftp、mail、local0、local1 的消息。这是我的 /etc/asl.conf 的粘贴:

 ##
 # configuration file for syslogd and aslmanager
 ##

# redirect com.apple.message.domain to /var/log/DiagnosticMessages
? [T com.apple.message.domain] store_dir /var/log/DiagnosticMessages exclude_asldb

# authpriv messages are root/admin readable
? [= Facility authpriv] access 0 80

# remoteauth critical, alert, and emergency messages are root/admin readable
? [= Facility remoteauth] [<= Level critical] access 0 80

# broadcast emergency messages
? [= Level emergency] broadcast

# save kernel [PID 0] and launchd [PID 1] messages
? [<= PID 1] store

# save everything from emergency to notice
#? [<= Level notice] store
? [<= Level critical] store

# save lpr info level and above
#? [<= Level info] [= Facility lpr] store

# save all mail, ftp, local0, and local1 messages
#? [= Facility mail] store
#? [= Facility ftp] store
#? [= Facility local0] store
#? [= Facility local1] store
Run Code Online (Sandbox Code Playgroud)


Che*_*ion 7

几周前我读过的一篇文章:缓慢打开终端窗口

/usr/libexec/path_helper加载速度非常慢/etc/paths如果您删除所有条目/etc/paths并确保这些项目在您的可用,.bash_profile这将解决问题。无论如何,它对我有用。