How Can I Speed Up Terminal.app or iTerm on Mac OSX?

23,353

Solution 1

Try deleting the Apple system log files in /var/log/asl/:

sudo rm /var/log/asl/*.asl

This did the trick for me.

Solution 2

Another tip might be helpful:

Change start up shell from default /usr/bin/login to /bin/bash -l, or /usr/bin/zsh if you use zsh.

That might make your Terminal/iTerm2 launch in light speed!

  • For Terminal: Preferences → Startup: Change from "Default login shell" to "Command: /bin/bash -l"

  • For iTerm2: Preferences → Profiles → General → Command: Change from "Login Shell" to "Command: /bin/bash -l"

Solution 3

Am I required a certain reputation to comment on posts? Anyway clearing the system logs did it for me as well, thanks. I have tried to patch path_helper with the patch here: gist.github.com/123525, as suggested in a comment on http://mjtsai.com/blog/2009/04/01/slow-opening-terminal-windows/ (referenced earlier in this thread) but to no avail. I get a cryptic error. However, that patch should speed up terminal.app launch.

addition: As I mentioned, clearing the logs did the trick for me, but the problem continues to emerge as the logs continously grow bigger after I've removed them. I found that "tweaking" /etc/asl.conf has given me a more permanent solution. The modification is to log only messages that are categorised as "critical" or more critical than that, as opposed to logging "notice" category and every more critical than that. Also, I disregard messages from ftp, mail, local0, local1. Here's a paste of my /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

Solution 4

From an article I read a couple weeks ago: Slow Opening Terminal Windows

/usr/libexec/path_helper is terribly slow at loading /etc/paths If you remove all the entries in /etc/paths and ensuring that those items are available in your .bash_profile this will resolve the issue. It did for me anyway.

Solution 5

My guess is that over time, something is using a lot of memory. When you startup a terminal after not using it for a while, some memory has to be made available by swapping its contents out to disk. If you kill the terminal process and restart it relatively quickly the memory is still available and it starts up quickly. This should happen with other applications as well.

You should monitor your memory usage with Activity Monitor and see if you can tell where it is going.

Share:
23,353

Related videos on Youtube

trapp
Author by

trapp

Currently the Director of Platform Services at Automattic, makers of WordPress.com, Polldaddy, Intense Debate, Gravatar, and more.

Updated on September 17, 2022

Comments

  • trapp
    trapp almost 2 years

    Every time I launch either iTerm or Terminal after not using it for a few hours, it takes anywhere from 10-20 seconds to return a prompt. The screen is blank, and although I can type I can't actually run any commands.

    If I quit either application, subsequent launches (if done relatively soon thereafter) are quite fast. The slowness only seems to occur if the app wasn't running for a few hours.

    I'm running OSX 10.5.7 on a MacBookPro. I have the exact same setup on another computer, with no slow downs.

    Any ideas how to speed things up again?

    • cregox
      cregox about 13 years
      I love how this question is asked and answered by two anonymous users with random numbers. I don't see this pattern that often! :)
    • rogerdpack
      rogerdpack over 9 years
  • Mike McQuaid
    Mike McQuaid almost 15 years
    He said that the Terminal window was open which means the process has loaded.
  • Arjan
    Arjan over 14 years
    @Mike, I am not sure that once the Terminal window is shown, everything has loaded? Still, if the above would be true for Terminal, then any program would launch slowly. I don't think Terminal needs a lot of resources (6.5/31.7 real/virtual on my Mac), so @pmaiorana: how much memory does Terminal needs on your Mac?
  • Arjan
    Arjan over 14 years
    (ASL = Apple System Log)
  • Arjan
    Arjan over 14 years
    Welcome at SU. Yes, 50 reputation is needed, but there's more to know, so head over to superuser.com/faq right away! ;-)
  • Chealion
    Chealion over 14 years
    Coincidentally someone rewrote path_helper and it's available at: github.com/mgprot/path_helper
  • Rogerio Silva
    Rogerio Silva over 13 years
    +1. Worked like a charm even though as one of the other answers suggested I have a non-trivial .bashrc.
  • Matthew Rankin
    Matthew Rankin over 13 years
    As pointed out on OsXDaily, I'd recommend using sudo rm -rf /private/var/log/asl/*.asl instead because it's safer as it 1) only deletes the log files and 2) avoids cding into the wrong directory and removing all files.
  • alvincrespo
    alvincrespo over 12 years
    This might be the problem I'm having, do you know how I can check If I'm using bash where I can access the .bashrc file?
  • James McMahon
    James McMahon almost 12 years
    Anyone have any idea why the size of system logs effect how fast the terminal opens?
  • brevno
    brevno almost 12 years
    @JamesMcMahon The login process seems to read all files and folders on the top level of /var/log/asl. Try running sudo opensnoop | grep /var/log/asl.
  • James McMahon
    James McMahon almost 12 years
    Ah, so the terminal wasn't a login shell it would open up faster. Interesting.
  • Sindre Sorhus
    Sindre Sorhus almost 12 years
    This sped up new tab loading considerably.
  • Nathan Long
    Nathan Long over 11 years
    What are these logs for? How are they different than shell history?
  • Michael Mior
    Michael Mior over 11 years
    You can also go into Terminal.app preferences and on the startup tab, set the command to your shell instead of the default login. login apparently reads the logs to find the last login time.
  • Sam Stern
    Sam Stern over 10 years
    Can't say how much this helped me. Solved ~6 months of slow terminal performance in 1 second.
  • Saro Khatchatourian
    Saro Khatchatourian over 10 years
    /bin/bash -l works for me!
  • 0 _
    0 _ over 10 years
    For those preferring to use the MacPorts bash: /opt/local/bin/bash -l
  • rogerdpack
    rogerdpack over 9 years
    apparently using /bin/bash -l isn't enough for yosemite (anymore?), for other deatils, see apple.stackexchange.com/questions/41743/…
  • michelgotta
    michelgotta over 7 years
    Deleting the log is fine, but after a short while the bash login process is slow again. The /bin/bash/ -l is a more forward-looking solution.
  • Justin
    Justin over 7 years
    both removing the asl and changing to /bin/bash -l didn't make anything faster for me. any other thoughts for troubleshooting this?
  • Chris Hough
    Chris Hough about 7 years
    did this change break your theme?
  • Franklin Yu
    Franklin Yu over 6 years
    Is it still the case? path_helper doesn’t seems slow…
  • user805981
    user805981 almost 4 years
    Could someone here please explain to me what exactly this is doing? I'm on MacOS Catalina? Thanks!