Bulk copying files on OS X

I recently bought a new 1TB hard drive to replace my measly 250GB media drive. I needed to clone the contents of the small drive onto the new drive.

You could just open up two Finder windows and just drag the folders but that’s tedious and if you accidentally click cancel during the copy process your kind of stuck.

This is a great example of a time to use the command line.

Apple bundles a couple of UNIX utilities that allow you to copy files around. We’re going to briefly explore three.

The first – CP is the traditional copy program.

Copying files with the cp command is simple. First, launch Terminal (in your /Applications/Utilities folder). Then, use the following syntax to create your command:

cp source destination

For example, to copy a file named MyFile.rtf from your Desktop folder to your Documents folder, you would type in the following command in Terminal and then press Return:

cp ~/Desktop/MyFile.rtf ~/Documents

Master the command line: Copying and moving files | Macworld

I tend to use cp when I’m copying a single file at a time.

The second program is ditto. Ditto preserves permissions when run as root and preserves resource forks by default. Ditto can be used to clone your system with the following step:

sudo ditto -X / /Volumes/Backup

Finally, there is rsync. The really cool thing about rsync is that it allows you to resume a copy that is interrupted. It’s also really good if you need to keep files in sync.

If you’ve never used rsync before then today is going to be a great day for you. Firstly, rsync is not new it’s been around for quite a while and chances are you’ve already used it without realising. One of the things I use it for most is to sync directories on your local machine (useful for creating backups to external devices) or you can sync with a remote connection. A Practical Guide to Using rsync – Created by Pete

In the end, I used rsync because I wanted to make sure if the copy was interrupted I didn’t have to start over.

I did it with this command.

sudo rsync -vaE --progress /Volumes/SourceName /Volumes/DestinationName

And my drive was backed up before I knew it.

CP, RSYNC and Ditto are all really powerful UNIX utilities to move files around on your Mac. If you’ve been afraid of using the command line you’re really missing out on some cool tools.

Make your Desktop less transparent in OS X 10.10 Yosemite

Yosemite intoduced a new visual style that for some takes a bit of getting used to. One of the things you might not like is the high level of transparency in the Dock. Luckily it’s easy to reduce the transparency in the Dock through your System Preferences.

To reduce the transparency, open System Preferences and clicks the Accessbility Preference Pane.

Yosemite Acessibility Preferences Reduce Transparency

Select Display from the options on the left. Then, click the Reduce transparency check box. The effects are immediate.

 

Quickly Hide Away the Icons on Your Mac Desktop

I use my Mac sometimes for presentations. When I do, I don’t like people seeing how sloppy my desktop is. If you’re like me you probably have a bunch of icons and folders cluttering up your desktop. You can drag them off your desktop and then put them back when you’re done your presentation but that’s a pain. Luckily there is a free and a couple of pay ways that will allow you to temporarily hide the desktop icons, while still keeping the originals in their location.

The free way is simple and involves tweaking a setting from the Terminal.

This first command will remove the icons:

defaults write com.apple.finder CreateDesktop -bool false && killall Finder

and this this second one will restore all the icons:

defaults write com.apple.finder CreateDesktop -bool true && killall Finder

If you want a more robust set of features, check out these two paid applications that will clean up your desktop and do a bunch more. First, there is Camouflage (US$5.99), which has been around for a long time and is regularly updated to support the latest version of OS X. There is also Desktop Curtain ($4.99). that supports a variety of options for setting the curtain coverage amount, extending the cover to external monitors and more.

Colorize LS and Terminal

I spent many years working on Linux. When I made the move to OS X I felt nearly at home.

One thing I missed when I made the switch was the bash shell didn’t print text in color. Also, OS X didn’t colorize the output of ls which made me sad.

For whatever reason, it bothered me in a particular way today and decided to finally get my terminal to print in color.

I poked around on the internet on some Linux websites and found that all I needed to do was add the following lines to my .bash_profile file.

PS1='\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\    [\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ '
alias ls = "ls-G"

Huh?

Yeah, that looks pretty crazy. Here it is broken down. You can go deeper by typing man bash

PS1 is the primary variable used to customize the prompt. Customization works by adding special backslash-escaped characters to the variables. In this example:

  • we are setting the colors with ‘\e[0;34m]’
  • we are displaying the username with ‘\u’
  • we are displaying an @ symbol with ‘\@’
  • we are displaying the hostname with ‘\h’
  • display the working directory with ‘\w’
  • end the prompt with $

The alias command will substitute the ls command with ls -G which gives you nice colorized output.

Enter this information into your .bash_profile and then test it by running the command
source ~/.bash_profile
which will update your current terminal to use the new settings.

Your turn.

I have a nicely formatted bash prompt now using the $PS1 variable. Have you made any of your own bash customizations? Share them in the comments.

Typing Special Characters on your Mac

Ever so often, you need to type a word with a special character such as a cedilla or an accent mark. Today, we’ll look at how to type these special characters known as diacritical marks in OS X along with some popular symbols. This list will come in very handy if you often write in a foreign language on a standard US English keyboard.

Character Name Keyboard Shortcut
é,á,í,ú acute accent Option+e, then the letter to be modified
è,à,ì,ù grave accent Option+`, then the letter to be modified
ê,â circumflex accent Option+i, then the letter to be modified
ö,ü,ä umlaut Option+u, then the letter to be modified
ñ tilde Option+n, then the letter to be modified
ç cedilla Option+c
¿ inverted question mark Option+?
¡ inverted exclamation Option+1
ellipsis Option+;
ß esszet Option+s
π pi Option+p
º degree Option+0
ø ø Option+o