Mac OS X Finder and Terminal Shortcuts

These are some of simple tricks that came across when I was working with Mac OS X - Yosemite. Most of them will work with older versions such as Mavericks and Mountain Lion.


How do you navigate to the '/usr/local' from the `Finder` program?

When you open the Finder you can only navigate into limited places(figure 1).

Figure 1: `Goto` places in Finder


But for a scenario such as navigate into '/usr/local'. How do you do that? It is simple. Just type following on the terminal;

open '/usr/local'

To get to know more about `open` command goto this link or type `man open`. Then `Q` to exit from the manual.

Open current path of the terminal in Finder?

Surprisingly YES from me. You can open your current terminal path on the terminal by typing(Note the dot);

open .

Open '/usr' on the File Open Dialog?

Yes, you can use 'GoTo' feature. Just press [⌘Command]+[Shift]+[G] on the file open dialog. Then type '/usr'. Voila !!!

Get current address of a file into terminal?

Just drag and drop the file/directory you want into the terminal.

Open a file in a user-specified texteditor using terminal?

You can create an alias for saving your time! Here how to do it. 

First we need to create/edit the ~/bash_profile file. You can use any simple texteditor such as nano or vim. I am using nano. In the terminal type;

nano ~/.bash_profile

If there are any existing data, don't do any changes for those and start from a new line and type;

alias te='open -a /Applications/Sublime\ Text\ 2.app'

Notice that I am defining a alias called `te` that executes the `open -a` command. Next part is the path for your text editor. Most of the time your already installed text-editor will appeared on the /Applications folder.

In nano editor once you done with adding the text, type [control]+[O] to write-out and press [Enter] to confirm. Then [control]+[X] to exit.  

Then type;

source ~/.bash_profile

This will reload your settings in the ~/.bash_profile into current terminal emulator.

Now you can use `te ~/Downloads/sample.txt` to open the `sample.txt` using the texteditor you chose. In my case, It is Sublime 2.

Show/Hide Hidden Files in Finder?

To show all hidden files, paste this in the terminal;

defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app

To hide all hidden files again, paste this in the terminal;

defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app
SHARE

Rasika Perera

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment