Mac OS X Terminal startup slow?

Tonight, I was finally fed up with my Terminal window taking nearly 10 seconds to show the initial prompt.  I regularly use Terminal to SSH into other computers and to commit and pull code changes in git repositories. The delay was annoying so I looked for help.

Mac OS X Terminal Window
I almost always finish typing my first command before the initial prompt appears.

Luckily, other people on the Internet have noticed the same issue so it wasn’t hard to find a solution. The first one I came across was on this blog post on OSXDaily. Initially, I was a little skeptical of log files having anything to do with the Terminal startup time, but other Google results also came up with the same solution.

The solution is to remove the *.asl (Apple System Log) files from the /private/var/log/asl/ folder. The Terminal command to remove those log files is:

sudo rm -rf /private/var/log/asl/*.asl

This is obviously a short term solution, as new log files will presumably accumulate over time again. I found additional information on SuperUser and ProposedSolution that you can check out, if you are looking for a deeper explanation and/or a long-term solution.

Using Mac’s Automator to Make Diffing Easier

Recently I’ve been needing an easy way to paste two versions of a text, and get the differences between the texts, specifically changes within a line (most diff programs only show which lines have changed).  After some searching, DiffMerge came up as one of the best free diff programs that would work on the Mac.  DiffMerge is great in many aspects, however, it lacked the interface to paste in text to diff right off the start.

I set out using Mac’s Automator tool to create an application to prompt the user for two texts, create the temporary files, then pass it into DiffMerge.

AutomatorPasteDiffAutomator is a very easy to use visual scripting tool that you can use to create workflows that can be automated (hence the name).  Also, it comes with all Macs!  As great as Automator seems to be, there are some drawbacks: the actions aren’t too customizable, and the flow of data within the workflow is strictly “output” of one action to the “input” of the next.

I came up with the following workflow:

  1. Get value of a pseudo-variable – random identifier
  2. Set the value of the random identifier into a variable so the same identifier can be referenced later (subsequent steps refer to this value as just the “identifier”)
  3. Ask for base text
  4. Store base text in a temporary file (using the identifier as part of the filename)
  5. Ask for new text
  6. Store new text in a temporary file (using the identifier as part of the filename)
  7. Get value of the identifier
  8. Run a custom shell script to open up diffmerge with the files created in the steps above.  Passing in the identifier as an argument of the shell script allows us to figure out the name of the temporary files.  The shell script also removes the temporary files when DiffMerge is closed.

The result was quite successful.  Here is what DiffMerge looks like after pasting in two SQL dumps into the Automator application.  Notice the temporary filename.

PasteDiffI’ve uploaded the app to do this on my GitHub account.  It’s called “PasteDiff.app”.  You can download them, and open the apps in Automator in order to see precisely the actions used.

Many times, computers programs are born out of necessity to reduce repetitive or menial tasks.  For Mac users, Automator’s a nifty tool that can help with that.

If you have used Automator for anything cool, let me know in the comments!

Saving keystrokes with a SSH client config file

I regularly have to SSH into my servers, and on most of the ones I connect to the SSH server is running on a non-standard port for obvious security reasons.  I used to include the port number manually in the SSH command, for example:

ssh seymour.dennistt.com -p 922

This worked… as long as I remembered to type the port number in, which was probably less than half the time on the first go.  So I finally got tired of having to retype the command with the port number in it.  Luckily you can create a SSH client configuration file which will remember this for you, and even give you a shortcut.
Continue reading “Saving keystrokes with a SSH client config file”

XDMCP Login from Mac to Lubuntu 11.10

My old desktops run Lubuntu (Ubuntu but lightweight!) 11.10, which just became part of the official Ubuntu release.  Life is a lot zippier in Lubuntu compared to Ubuntu when you’re on Pentium III and Celeron machines.

I wanted to be able to login to these computers remotely with a GUI, sort of like Microsoft’s Remote Desktop but Linux style.  I didn’t want VNC because I wanted to be able to create a new login session instead of using the main console. Luckily XDMCP does exactly that and most of it is built into Ubuntu.

The Setup

Following one question previously posted on AskUbuntu, I proceeded to add the following snippet to /etc/lightdm/lightdm.conf:

[XDMCPServer]
enabled=true

Logging In

Then following the procedures posted by David Winter, I opened Terminal on my Mac, and typed in: /usr/X11R6/bin/X -query 192.168.0.1 (replace 192.168.0.1 with the IP address of your Lubuntu computer).  After a few moments the Ubuntu login screen showed up.  Perfect!

Terminal Shortcut

I made myself an alias so that I wouldn’t have to remember the complicated command line.  In ~/.bash_profile, I added:

alias xdmcp="/usr/X11R6/bin/X -query"

So now I can start a XDMCP session by typing in

xdmcp 192.168.0.1