Tag Archives: MacOS

change default application open files mac os x




清空打开文件context menu的选项



1: Set the Default Application for a Specific File in Mac OS X

This provides file-specific control over default applications, meaning you can have a document or two that open in one app, while the overall general file type defaults to open in another application. For example, you could set one single PSD file to always open exclusively in Pixelmator, while all other PSD formatted documents continue to open in Adobe Photoshop.

  1. From the OS X Finder, right-click (or Control+Click) on the file to change the default app for and hold down the OPTION key so that the “Open With” menu becomes “Always Open With”
  2. Continue to hold OPTION and select the application you want to set as the default for this file

Set the default application for a file in Mac OS X

The file will open in the application you selected, and that file will now associate the chosen application as it’s new default to always open within.

By the way, if you’re setting a file type this way and notice duplicate entries in that Open With menu, you can remove those duplicate entries with this quick trick to clean up the Open With contextual menu.

Again, this is specific to the file you chose, and this method will not apply to all files sharing that same file format. If you want to set the default application universally for a file type, that’s what the next tip is for.

2: How to Set Default Applications to Open All Files of a Format Type in Mac OS X

This approach will change the default application universally for all files of a specific format. For example, you could use this to set all files of the type PNG to open within Skitch, all TXT files to open with TextWrangler, and all ZIP files to open with The Unarchiver.

    1. From the Mac file system, select a file of the general format type you wish to change the default application for
    2. Pull down the “File” menu and choose “Get Info” (or hit Command+i) to access the Get Info window
    3. Click the “Open with:” sub menu, then click on the contextual menu and select the new application to associate all files of this format type with

Change the default application for all files of a format to be associated with

    1. Click the “Change All” button and confirm the change when requested

Change All files of a type to always open with the set application

  1. Close out of Get Info, repeat for other file format types if necessary

(Note: if the Change All button is greyed out and unclickable it’s because you have not set an application that is different than the currently set default app. Use the pulldown menu to choose the new application for the Change All button to be usable and to apply the adjustment to all files of the file format type)

This change carries throughout all files of that format used within Mac OS X for the active user account, and the filetype-to-application association will stay in place until it has been changed again through the same “Get Info” trick, or until a third party application claims the file format and associates with it directly.

You’ll find this one particularly useful if a newly installed application has assumed control over a file format, like what often happens with Adobe Reader claiming all PDF documents. This ‘Change All‘ trick will allow you to quickly reclaim PDF file types to reopen again in Preview (or your app of choice), which is typically much faster than launching such files in more resource heavy apps like Reader.

The video below demonstrates the latter trick, changing the default application for all files of a given type:

Finder plugin “cd-to”



Posted on December 5, 2012 by in Tools


Mac Tips For iOS Developers

In a previous post I mentioned iTerm2 as a Mac OS X terminal replacement . Hopefully you’ve taken the time to check it out. If so, and you appreciate all it has to offer, the next step is to find a means to easily open iTerm2.

I have a number of scripts (Applescript code) that I have written and saved as applications. I then add the application to the toolbar in Finder. My toolbar looks as follows, all of the icons in the green box I’ve added:

Let me walk you through the steps to create a script that will open a new iTerm2 window and change to the current Finder path. I’ll also show you how to create an icon for the application so it is easy to recognize in Finder.

First, open up the AppleScript Editor and copy/paste the code below (code courtesy Stefan van den Oord):

-- Stefan van den Oord, 2010-12-29
-- The "cd to" command for iTerm2
tell application "Finder"
  set _cwd to POSIX path of ((folder of (front window)) as alias)
end tell
tell application "iTerm2"
    set _session to current session of current terminal
  on error
    set _term to (make new terminal)
    tell _term
            launch session "Default"
            set _session to current session
    end tell
  end try
  tell _session
    write text "pushd \"" & _cwd & "\""
  end tell
end tell

– Save the file as an application.

Before we drag/drop the application onto Finder, let’s create an icon for the application.

– Go to Iterm2 and use the Mac copy to clipboard feature (shift-command-4) to copy the logo.

– Open the screenshot in Preview, mark the image (control-a) and copy to clipboard (control-c).

– Find the application you saved above, right click and select Get Info .

– Tap the icon in the upper left corner and paste the saved image (control-v).

You now have Applescript that has been saved as an application, with a shiny new icon.

The final step is to drag the application onto the Finder toolbar.

You are good to go, iTerm2 at the current Finder path, one click away.





see other solutions



System Integrity Protection On Mac OS X EI Capitan


当我们在EI Capitan上安装 CocoaPods的时候,安装完成后,运行pod命令时,老是报错: pod command not fund!

只有我们重新安装pod,并显式地指定安装目录,才解决这个问题,原因就是EI Capitan不允许用户修改部分系统文件夹,比如/System,/bin等,即使使用sudo。具体原因请参考:http://apple.stackexchange.com/questions/193368/what-is-the-rootless-feature-in-el-capitan-really





8个不可不知的Mac OS X专用命令行工具






An A-Z Index of the Apple OS X command line


OS X的终端下通用很多Unix的工具和脚本。如果从Linux迁移到OS X会发现很多熟悉的命令和脚本工具,其实并没有任何区别。

但是OS X也提供了很多其他系统所没有的特别的命令行工具。我们推荐8个这类的工具,希望有助于提高在Mac的命令行环境下的效率。

1. open


$ open /Applications/Safari.app/

如果open一个文件,则会使用关联的程序打开之。例如open screenshot.png会在Preview中查看图片。


open一个目录会在Finder窗口中打开此目录。一个很有用的技巧是open .打开当前目录。


2. pbcopy 和 pbpaste


$ ls ~ | pbcopy



$ pbcopy < blogpost.txt


$ curl http://www.google.com/doodles#oodles/archive | grep -A5 'latest-doodle on' | grep 'img src' | sed s/.*'<img src="\/\/'/''/ | sed s/'" alt=".*'/''/ | pbcopy


$ pbpaste >> tasklist.txt

3. mdfind

许多Linux用户都发现Linux下查找文件的方法在OS X上不好用。当然经典的Unix find命令总是可以,但既然OS X有杀手级搜索工具Spotlight,为什么不在命令行上也使用一下呢?



$ mdfind -onlyin ~/Documents essay

mdfind的索引数据库在后台自动更新,不过你也可以使用mdutil工具诊断数据库的问题,诊断mdfind的问题也等同于诊断Spotlight。如果Spotlight的工作不正确,mdutil -E命令可以强制重建索引数据库。也可以用mdutil -i彻底关闭文件索引。

4. screencapture

screencapture命令可以截图。和Grab.appcmd + shift + 3cmd + shift + 4热键相似,但更加的灵活。


$ screencapture -C -M image.png 


$ screencapture -c -W


$ screencapture -T 10 -P image.png


$ screencapture -s -t pdf image.pdf

更多用法请参阅screencapture --help

5. launchctl

launchctl管理OS X的启动脚本,控制启动计算机时需要开启的服务。也可以设置定时执行特定任务的脚本,就像Linux cron一样。


$ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

运行launchctl list显示当前的启动脚本。sudo launchctl unload [path/to/script]停止正在运行的启动脚本,再加上-w选项即可去除开机启动。用这个方法可以一次去除Adobe或Microsoft Office所附带的所有“自动更新”后台程序。




6. say

say是一个文本转语音(TTS)的有趣的工具,引擎和OS X使用的一样也是VoiceOver。如果不加其他选项,则会简单的语音朗读你给定的字符串:

$ say "Never trust a computer you can't lift."


$ say -f mynovel.txt -o myaudiobook.aiff



可以在系统设置(System Preferences)的字典和语音(Dictation & Speech)选项中调整系统的语音选项甚至是语音的语言。

7. diskutil

diskutil是OS X磁盘工具应用的命令行版。既可以完成图形界面应用的所有任务,也可以做一些全盘填0、全盘填随机数等额外的任务。先使用diskutil list查看所有磁盘的列表和所在路径,然后对特定的磁盘执行命令。


8. brew

Homebrew程序提供的brew,严格来讲不是一个OS X的原生命令,但任何一个OS X的专业用户都不会错过它。“OS X缺少的包管理器”这个评价是恰如其分的。如果你曾经在Linux上使用过apt-get(或其他包管理器——译者注),你就会发现Homebrew基本上是一样的。

使用brew可以简单的获取数千种开源工具和函数库。例如brew install imagemagick就可以安装ImageMagick(几乎可以处理任何图像问题,转换任何格式的图像工具),brew install node可以安装Node.js(当前大热的服务器端JavaScript编程工具)。

也可以通过Homebrew做有趣的事情:brew install archey会安装Archey(在启动命令行时显示苹果LOGO和计算机硬件参数的小工具)。



最后,这里还有一篇OS X所有命令的完整列表

8个不可不知的Mac OS X专用命令行工具
原文:Eight Terminal Utilities Every OS X Command Line User Should Know