Category Archives: OSX

Mac OS X Bag of Tips

Every day, I spend most of my work hours at the OS X terminal. Consequently, I accumulated a few tips and tricks I would like to share with the readers.

Selecting Text

  • To select a word, double click on that word. The terminal is smart enough to discern when the period acts as a sentence terminator and when it is part of a file name. In the later case, the whole file name is selected. After double clicking and before releasing the mouse button, the user can drag the mouse to select additional words
  • To select a line, triple click on that line and drag the mouse up or down to select additional lines
  • To select space-delimited text, hold down Command and Shift and double click on the text. This action is useful for select path names. If the path name contains one or more spaces, drag the mouse to select the rest
  • If the user holds down the Command and Shift keys and double click a URL, OS X will open that URL in the default browser
  • If the user holds down the Option key, the mouse pointer will change to a cross hair for selecting column of text. An example of this application is for selecting the output of the ls command

Windows Management

  • The Command+1 combination will bring the focus to the first window, Command+2 to the the second and so on.
  • The Command + left/right arrows switch between terminal windows
  • Like other OS X applications, the Command + ` also switches between windows
  • The Shift + Command + [ or ] combo switch between different tabs
  • The Command + up/down arrows scroll through the window’s buffer, one line a time; the page up/down keys scroll one screen.
  • The Window > Split Pane menu or Command + D will split the window into two panes–useful for scrolling back to review previous text and/or select them

Saving a Transcript

  • To save the plain text transcript of all interactions since the window opened, click on the Shell > Export Text As… menu
  • To save the PDF transcript, click on the Shell > Print…, click the PDF button and select the appropriate choice

Window Group

I usually open two windows and arrange them side by side. Window group is a nice feature which helps me defining a group of windows for later use. To define a window group, first open as many windows as you would like and arrange/resize them. Next click the Window > Save Windows As Group… menu and give it a name. The “Use window group when Terminal starts” check box is self-explanatory.

Conclusion

These are just a handful of tricks that I can remember. I am sure the Terminal has more up its sleeve, waiting for us to discover. If you know a trick, please feel free to comment.

Advertisements

Share Your Printer in Snow Leopard – How To

This tutorial solves the following problem: the user wants to print to a printer attached to another Mac.

Open the System Preferences

media_1252769931991.png

Click on the Apple menu at the top left corner of your screen, then click on "System Preferences"

Open Print & Fax

media_1252769994132.png

Locate and click on this icon

Turn on Sharing

media_1252770020623.png

(1) Click on the printer you want to share, then (2) Turn on the share check box.

On the other computer, add a printer and you will find this printer in the list of shared printers.

Replacing My Laptop’s Hard Drive

I purchased my MacBook in the second half of 2007 with a relatively large hard drive of 60GB. Remember, 60GB is sizable in 2007. I then replaced it with a 160GB drive and even that drive now is full. My hard drive du jour is a 500BG, which should last me a couple of months while waiting for the 5TB version 🙂

Backing Up

Last night, my hard drive arrived from NewEgg and I started my upgrade process. The first order of business was to take inventory of the applications I currently have in the system and kept track of this list using a plain text file. I am not going into details on the how part–that’s another topics for later. Next, I went through my list and hunt down the product key (AKA license code) for each application. Since I use 1Password to keep track of my lincense codes, the process was fairly painless.

Next, I fired up iBackup and backed up some application settings and data I would like to carry over to the new system: Address Book, iCal, keychains, and mail. I used one of my external hard drive as backup destination. I also used iBackup to copy over the one application which the installation CD was damaged: Toast Titanium 7. Yes, that ancient version is still working with Leopard and I see no need to upgrade.

Before I turned off the laptop to perform surgery on it, I make a final back up using SuperDuper!. Upon finishing backing up, I restarted the laptop and booted from the backup drive to verify it was bootable and made a few checks to see if SuperDuper! correctly backed my files. Finally, I turned off the laptop and replace the hard drive. Again, I am not going into details of how I did it, there are plenty of help if you search the internet for it.

OS Installation

Once the new hard drive is in place, I used the Leopard installation disc to install Leopard onto the new hard drive. After installation, I immediately ran Software Update to bring my system up to date. This process required one reboot.

Restoring Mail, Address, and Other System Data

Right after the OS installation, I downloaded the latest version of iBackup and restored the data which I backed up earlier. To test how well iBackup performed, I fired up the Mail application and saw that all of my mail settings and messages were still there. I am glad that I donated to iBackup. This software is a must-have.

Another must-have I installed right away was 1Password since it stored all of my software license keys. Finally, I scanned through my application list and classify them as followed:

  • Must have. These are the applications I would need. Examples in this category includes 1Password, Aperture, Backblaze, and SuperDuper!
  • Unwanted. These are applications that either I don’t like or don’t need. For example, I don’t need the EPSON scan application because the built-in Image Capture application can scan just as well.
  • On Demand. These are applications which I rarely need and I will install them when the need arise. Applications such as the Logitech Harmony Remote Software, Garmin and RegExhibit fall into this category.

I am now in the process of installing my must-have applications, one at a time and verifying that they are working correctly. This process should take a day or two to complete.

Conclusion

Replacing a hard drive is not hard, but it does take some planning to reduce the risk of losing data. Imagine having to re-type 250 contacts because you forgot to make backup! I hope you enjoy this post and post any comment, correction, or questions to the blog.

Changing Directory Listing (ls) Color in Linux and Mac OS X

Problem

I practically “live” on the Linux command line and one thing that has been bugging me for so long that now I decided to do something about it. On my company’s Linux systems the ls command produces color output, which makes it easy to distinguish different file types. However, the directories are dark blue which makes it nearly impossible to see against the black background.

My Solution

To fix the problem, my research took me to the LS_COLORS environment variable and a command named dircolors. The solution is to set the LS_COLORS environment variable to control how the ls command chooses its color. I can set the LS_COLORS variable manually, but there is a better way which employes the dircolors command.

The dircolors command output commands to set the LS_COLORS environment. It also output the colors in human-readable format, allowing easy modifications.

To use the dircolors, the first step is to save the current settings into a file. From the terminal, I issued one of the following commands:

    dircolors -p > ~/dircolors.txt

The next step is to edit the file ~/dircolors.txt. This file’s format is easy to understand and self-documented; I had no problem finding the file that begins with “DIR” and change the color to my taste.

Next, I try out the new color scheme:

    eval $( dircolors -b ~/dircolors.txt ); ls # bash shell syntax
    eval `dircolors -c ~/dircolors.txt`; ls # C shell syntax

After finding the color scheme I liked, I saved it to my start up file:

    dircolors -b ~/dircolors.txt >> ~/.profile # bash shell
    dircolors -c ~/dircolors.txt >> ~/.cshrc   # C shell

From this point on, I no longer have to put up with hard-to-see colors.

Solution for BSD Systems

On BSD systems, which includes the Mac OS X, the variable in question is LSCOLOR (note the lack of the underscore character). The format of this variable is different from the Linux’s LS_COLORS. The default is exfxcxdxbxegedabagacad. The value of this variable consists of pairs of characters; the first character is the code for foreground color, and the second is for background. Please consult the man page for ls on BSD for more information.

The Interactive Solution

While I like to do things the hard way to learn more about the inner-working of the OS, there is a more interactive way: point your browser here to an interactive online web application which assist you in setting the colors. After finding your desired color scheme, you still have to cut and paste it to your start up file.

Additional References

Google is your friend: do a search for LSCOLORS or LS_COLORS will result in more information that you ever care to read.

iTunes: Move to Trash Shortcut

I often need to delete old podcasts to make room on my hard drive. My preferred way to delete an item is to highlight it, then hit the delete key. iTunes then displays a dialog similar to this one:
iTunes dialog asking to keep the file or move it to the trash
Since the “Keep File” button is highlighted, it is the default action if the user hits the return (also known as the enter) key. Instead of hitting the Cancel button to abort the operation, the user can hit the esc key. What about the “Move to Trash” button? After a few trials, I found it: just hit the m key and iTunes will move the item to trash. I have tested this shortcut on the Mac OS X environment, so I am not sure if it works in Windows.

If you know any useful shortcut keys that are off the beaten path, please share them via the comment section. Thank you.

Switching Between OS X Terminal Windows

Terminal is my bread and butter at work and I usually have more than two Terminal window up side by side and switch between them. Here are some trick I learnt:

  • To switch between the windows, use Command+`
  • To jump to the first window, use Command+1. To jump to the second window, use Command+2 and so on
  • If you have several tabs (new in Leopard), use Command+Shift+[ and Command+Shift+] to jump to the previous and next tab, respectively.
  • Alternatively, you can always use the mouse to click on a window or tab to switch to it.
  • I found out this cool tip which put the focus on the window by merely move the mouse cursor to it: from the terminal, issue the following command: defaults write com.apple.terminal FocusFollowsMouse -string YES and restart the terminal for the change to take effect. Thanks to CLIX (a fantastic collection of command-lines) for this tip.
Overall, I use the Command+<number> quite often, and rarely use the mouse.