Archive

Archive for the ‘Mac OS X’ Category

Mac OS X – Quick way to get a long path into a terminal window

June 16th, 2010

As noted in this post, there is no way to right-click a folder in the Finder and copy it’s full path to the clipboard. This is an annoying omission in OS X that can make life difficult for software developers and power users.  But I just discovered a neat trick: you can simply drag the folder icon from the Finder into the Terminal window.

So for example, bring up a terminal window and type “cd ” (notice the space after “cd”). Then simply drag your folder from the Finder onto the terminal window, let go and you’ll be ready to hit the return key to change directory to that long path rather than having to type the whole thing out.

Charles Newman Mac OS X

Mac OS X – Rename a bunch of files quickly

December 18th, 2009

Let’s say I have a bunch of files with the extension “.abc” and I want to change all of them to end with “.doc”.  I can rename each one individually in the Finder, but that could take a long time if there are a lot of files.  Especially considering the warning the Finder gives you about changing the file extension.

A much faster way to do it is to launch the Terminal application, “cd” to the directory where your files exist, and use this command:

for f in *.abc; do mv ./”$f” “${f%abc}doc”; done

All of  your “*.abc” files will be changed to “*.doc”.

Charles Newman Mac OS X

Adobe Media Encoder CS4 for Mac – Can’t set the CBR bitrate

July 30th, 2009

So you sit down to encode some content at varying bitrates so you can dynamically stream your content. You start with a low bitrate. Then you duplicate that one so you can do another at a higher bitrate with the same settings. But before you hit “Start Queue” you decide to double check that last one and make sure you set the bitrate to what you thought you set it to. But no, it’s set to the first one. You do it a few more times and… …what the f*#%! The bitrate change will not stick! This is an incredibly annoying bug.

The only way I’ve found to make it “stick” is to select VBR, set your desired bitrate, then choose CBR. It sticks when you do that. How this got past the QE’s at Adobe I have no idea.

Charles Newman Adobe Media Encoder, Mac OS X

Mac OS X – Firefox preferences and windows open off screen

June 29th, 2009

If you use two monitors and then remove one, for example from your laptop, you may notice that Firefox thinks the other monitor is still there and opens it’s preferences and windows off screen. To fix this without re-connecting the monitor:

1) Quit Firefox
2) Hold down the option key while you start Firefox
3) Select “Reset toolbars and controls” and click “Make Changes and Restart”.

ff-reset

Charles Newman Firefox, Mac OS X

Mac OS X – show the full path in the Finder window

June 23rd, 2009

One of the things missing from OS X is the ability to ctrl+click a file and copy it’s full path to the clipboard. It amazes me that this feature is missing from such a robust OS. This tip should make your life easier. You can see the full path in the title bar when you select a file in the Finder.

1) Open a Terminal window and type this command:
defaults write com.apple.finder _FXShowPosixPathInTitle TRUE
Of course replacing TRUE with FALSE will turn this feature off.

2) Restart the Finder:
Cmd+Option click the Finder in the Dock and select "Relaunch"

Note this works from User accounts as well as Admin accounts. No need to “sudo” from within the User account.

Charles Newman Mac OS X

Mac OS X – Make your Mac talk

May 21st, 2009

Okay this one goes in the “useless but fun” category. Open the Terminal application and type this:

say "I hate Windows"

Kind of like a 3 year old kid, your Mac will say anything you tell it to.

Charles Newman Mac OS X

Mac OS X – Easy way to do a hex dump of a file

May 12th, 2009

Occasionally, as a developer, I have a need to do a hex dump of a file to inspect extraneous tab characters, extra newlines, etc. On the Mac, you can easily do this on the command line.

With this command, you can get a nice, side-by-side hexadecimal and ascii view of the first 128 bytes of a file without downloading any shareware or other development tool:

hexdump -C -n128 myfile.ext

Charles Newman Mac OS X

Mac OS X – Why does the delete key act like a backspace key?

May 6th, 2009

New Mac users always ask this. To make the delete key act like it does in Windows, hold down the fn key while pressing delete.

Charles Newman Mac OS X

Mac OS X – Create an Alias by Clicking and Dragging

May 1st, 2009

An “alias” in OS X is a symbolic link, or essentially a reference to another file. It is not a copy of the file, just a pointer to it. So for example, if you find yourself digging through folders in the Finder for the same document every day, it might be more efficient for you to place an alias of the file on your desktop.

To do that, simply drag it from the Finder window and hold down the Cmd (or Apple key) and the option key while you drag. Let go and you have your new alias.

You can also create an alias by selecting the file (single-click) and then typing Cmd l (that’s a lower case L). This will create an alias right next to the file it references. You can then drag the alias, or cut and paste it anywhere you like.

Charles Newman Mac OS X

Mac OS X – Starting/Stopping Apache

April 23rd, 2009

Every Web developer needs to test files with a Web server and the most convenient way to do that is to run a Web server locally on your development machine and access it via localhost (127.0.0.1). One of the reasons Macs make such great dev machines for Web developers is they come standard with almost everything you need: Apache, MySql, Python, Perl, PHP, Java, etc.

From a Terminal window, these commands will start or stop Apache:

  • sudo apachectl start
  • sudo apachectl stop

After you’ve started Apache, browse to this address and you’ll see the standard Apache page:
http://localhost

The default location of the web site files on your file system is called the document root, and that is here:
/Library/WebServer/Documents

If you use this address:
http://localhost/~yourname

Those files are here:
/Users/yourname/Sites

Trouble shooting
If the default Apache page doesn’t load when you click http://localhost, check to make sure the Apache process loaded. You can type this into a terminal window to verify that Apache is loaded:

ps acx | grep -i 'httpd'

If you don’t see anything returned that means Apache failed to load. To find out why, run the Console app (you can find it in /Applications/Utilities or just type “console” into Spotlight). Click “All Messages” and you should see something like this:

httpd: Syntax error on line 117 of /private/etc/apache2/httpd.conf...

In that case just open the httpd.conf (you will probably need to “sudo vi httpd.conf”) and make adjustments. You may need to comment out some mods that are failing to load, or you need investigate what is wrong with the offending mod.

Charles Newman Mac OS X