terminal

How to run a Unix shell script from the Mac Finder

If you ever want to create a Unix shell script that you can give to someone else so they can double-click it and run it through the Mac OS X Finder, all you have to do is (a) name the file with the ".command" extension and (b) make it executable. So, just name your Mac/Unix script like this:

ShowProcesses.command

Then make it executable, like this:

chmod +x ShowProcesses.command

You can also leave out the usual #!/bin/sh part on the first line.

A sample Mac OS X Bash startup file (.bash_profile)

In case anyone needs a sample .bash_profile startup file for their Mac OS X or other Unix/Linux system, I thought I'd share my most recent version here.

Mac OS X debug tip - Check the log files

Mac OS X debug FAQ: Help, I'm having a problem with [fill in the blank] on my Mac OS X system, how do I troubleshoot it?

I just ran into a problem when trying to create a Safari web clip dashboard widget, where the web clip isn't properly updating itself, and I stopped for a moment to think about how to troubleshoot/debug this Mac OS X problem. That's when I thought, "Okay, a Mac is a Unix system, check the log files." So I cracked open a Mac Terminal window, and checked the system log file:

AppleScript from Unix - Get the current Mac foreground application name

AppleScript foreground application FAQ: How can I get the name of the current Mac OS X foreground application in AppleScript?

Use AppleScript to display a dialog from the Mac OS X Unix shell

Mac Unix shell AppleScript FAQ: How can I display a dialog with AppleScript from the Unix command line shell? (Either from a command line shell like bash through the Mac OS X Terminal, or from a shell crontab job.)

How to use Spotlight to search for files from a Mac OS X Terminal window

If you ever want to use the Spotlight search functionality from a Mac OS X terminal window, you can access the same Spotlight information using the mdfind command. Here are a few examples of how to use mdfind to find files and directories on your Mac OS X system.

To find files with the word "alexander" in them, from a Terminal window you can use mdfind like this:

mdfind alexander

Now, if you just want to find a file using a portion of the filename, use this mdfindcommand:

AppleScript Unix Terminal: How to run an AppleScript from Unix

AppleScript Unix Terminal FAQ: How can I run an AppleScript script from the Mac Unix terminal (Unix command line)?

A cool thing about Mac OS X is that you can run AppleScript programs from the Unix shell. (Well, I guess it's cool if you're a Unix user, and I am.)

Running an AppleScript program from the Unix shell turns out to be surprising easy. For instance, if my current working directory has a script named OpenUrls.scpt in it, I can run that script from the command line like this:

Finding files that Spotlight is missing

I generally use Spotlight when searching my Mac for a file, but there are times it doesn't work, especially when I'm trying to find a file that contains a phrase I know. For instance, I may have a file named "Fred.txt", and it contains the phrase "foo bar", but when I open Spotlight and type in "foo bar", the file Fred.txt never shows up.

Mac Terminal - disable blinking text

Working on my Mac OS X system, when I use the ls command on a remote system, that system is configured to show blinking text for all files ending with the ".sh" filename extension. If you've ever had to look at blinking text when trying to read output from an ls command you know that can be really annoying. (Is there ever a time that blinking text isn't annoying?)

So, to disable blinking text in the Mac OS X Terminal application just follow these steps:

Mac Terminal title - Change the Mac Terminal title from the command line

Mac Terminal title tip: How to change the Mac Terminal title from the Terminal command line.

I've been working on a project where I have three Mac Terminal windows open at one time, and I found it was much easier to work this way when I changed the Mac Terminal title on each Terminal window. This helped me easily identify what I was doing in each Mac Terminal window.

Changing the Mac Terminal title

The basic escape sequence you need to change the Mac Terminal title from the command line is this:

Syndicate content