Make Hidden Apps Translucent in Mac Dock

I had no idea that you can make your dock icons transparent when you hide an app. In fact, I didn’t even know you can ‘hide’ apps….I always just either used ‘alt+tab’ to switch between apps, or minimized them.  So I learned something!

To make your hidden app icons turn translucent in the Dock, all it takes is a simple Terminal command:

defaults write com.apple.Dock showhidden -bool YES

Then, you need to restart the Dock, which you can do using

killall Dock

To reverse this setting, simple run “No” instead of yes

defaults write com.apple.Dock showhidden -bool NO

Oh, and also the keyboard shortcut for hiding an app is “cmd+H”

credit here

Advertisements

Add Git Autocomplete to Terminal

A nifty edition to the git command line is autocomplete. First, get the git completion script:

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

Then edit your ~/.bash_profile file to add the following code:

if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash
fi

(go here for help on editing your .bash_profile)

That’s it. Now you can type git and press Tab twice to get an autocomplete list of commands.

credit:

http://apple.stackexchange.com/questions/55875/git-auto-complete-for-branches-at-the-command-line/55886#55886

http://code-worrier.com/blog/autocomplete-git/

Open URLs and Applications from Terminal and Ruby Scripts

Did you know you can open applications directly from the command line in Terminal?  The command is open

To open a url in the browser from the command line, use

open http://www.apple.com/

You don’t need quotes around the url. This will use the default browser on your machine.

The line

open /Applications/

will open the Applications folder in Finder.

To open a specific application, use the path to that application followed by the .app extension.

open /Applications/Airdroid.app

(Airdroid is a great application for transmitting files from your computer to phone wirelessly.)
If you want to open Sublime Text from the terminal, you can use the command subl

subl .

Will open the current directory in Sublime Text.

If you’re writing a ruby script, use these commands instead:

system("open", "http://stackoverflow.com/")
system("open", "/Applications/Adobe\ Illustrator\ CS6/Adobe\ Illustrator.app")

credit here

Double Press Tab in Terminal for List of Options

I accidentally found a really cool Terminal keyboard shortcut yesterday.  You may already know that Terminal will autocomplete a file name or method name if you press tab after typing a portion of the word.  For example:

Screen Shot 2014-12-31 at 8.14.50 AM

You can see I typed ls to list the files and folders in the current location. Then I started typing cd Fi to change the directory to “FiveMinuteChinese”. As a shortcut I can now press the Tab key, and Terminal will autocomplete the folder name:

Screen Shot 2014-12-31 at 8.18.42 AM

 

Now what I just learned was that if you press the Tab key twice, Terminal will show you a list of possible options. See the screenshot below:

Screen Shot 2014-12-31 at 8.20.18 AM

 

Here I typed cd C, then pressed Tab twice, and Terminal gave me a list of all files or folders that start with the letter “C”. Pretty cool huh? If you’re using irb or another console type environment, you can use this same shortcut to give you a list of possible methods or autocomplete method names.

Hope this is useful!

Remove a non-empty directory in Terminal

I love using the command line like a ninja, but its also really annoying when you don’t know the exact right command or option.  I was trying to delete a directory the other day, and kept getting the annoying error “Directory not empty”

Screen Shot 2013-08-03 at 11.37.20 AM

So here is how to fix it.  I found the answer here, as I will outline below.

Use the ‘-R’ option with the ‘rm’ command to delete an empty directory.  If the directory has relatively few files, I recommend using the ‘-i’ flag, as that will ask you to confirm each file to delete.   See the screenshots below for an example:

Screen Shot 2013-08-03 at 11.41.14 AMHope you found this useful!

Reduce the size of Time Machine Backups

I found this great blog post by Hawk iMedia that details a very simple utility to compress or compact your time machine backups.  If you’re like me, Time Machine is way overkill.  I just want one viable backup that is fairly recent.  Not daily/hourly backups until my entire 3TB backup hard drive is full, as Time Machine will do by default.  So I roll with automatic backups turned off, and just manually backup occasionally.

Anyway, the Time Machine backup file (.sparsebundle) was taking up 1TB on my Time Capsule drive, even though my Macbook Pro only has a 500GB SSD hard drive.  So based on the aforementioned blog post, here is how to reduce the size of your Time Machine backup by compacting or compressing the .sparsebundle file.

Its basically just calling a “hdiutil compact” command on the sparsebundle file.

First, open Finder (or my favorite replacement, TotalFinder) and navigate to the folder where you’re sparsebundle file is located. Or in Terminal you can use the “ls” and “cd” commands to navigate through the folder structure. The “cd ..” command moves up one folder.  Here is what my Terminal commands look like:

Image

If like me one of the directories or folders has spaces or special characters in the name, this nifty trick will help you navigate to that folder.  Now you also need to be root to run the “hdiutil compact” command, so sudo into root.  You will need to enter your admin password.  You should be aware that if you run the wrong commands in root, it is possible to mess up your system.  However, just type in the commands directly and you’ll be fine.

Image

Image

And, you’re done!  So easy!  Now, I know that it shows “0 bytes reclaimed” on my system.  But after I ran this command on both mine and my wife’s sparsebundle backup files and got that message, I checked my Time Capsule and found that it was reclaimed 800GB of free space!!  So it definitely works.  Try it out!