I have a hidden file (.htaccess). When I double click it I would like it to open with a certain app (Sublime Text for this particular file type). In order to set the default app I have to open the "Get Info" window for that file (Cmd+I).

However, that file is hidden. So I can't right button click (two-finger tap) it to select the "Get Info" option from the context dropdown menu.

So the question is how do I open the "Get Info" window for a hidden file? The goal is to be able to change the default app for that file type.

p.s. I do not want to make my hidden files visible. Even temporarily.

  • Please consider editing your question so that it becomes a bit more clear what you want to achieve; as I said below 1) you can only change the default text editor for all text files, not just .htaccess, see also here 2) you can not click on invisible files without making them visible first. Apart from using the command line I'd only suggest using the Open Dialog from whichever Editor and pressing <kbd>cmd</kbd>+<kbd>shift</kbd>+<kbd>.</kbd> to make hidden files temporarily visible. – Asmus Jul 3 '14 at 17:59
  • made the changes. Thank you for the link - installed the app, made the changes, however it didn't affect anything. :-( Good trick with Cmd+Shift+. - but again no help, as context menu is very limited in the "Open" dialog. In particular it doesn't have the "Get Info" option. – Geo Jul 4 '14 at 22:28

You can use the following shell function. This uses open information window which is much better than GUI scripting or keyboard shortcut scripting which relies on the file shown in Finder.

si() {
    osascript - "$@" <<-END > /dev/null 2>&1
    on run args
    tell app "Finder"
    repeat with f in args
    open information window of (posix file (contents of f) as alias)

Source: https://superuser.com/a/509080/

Run with

si /path/to/file
  • Ah, that's clever! :-) Didn't now about open information window before! Even though this won't help in the end with Geo's problem of opening .htaccess files in specific editors, have an upvote! – Asmus Jul 3 '14 at 9:03
  • 1
    I don't understand how to write this in terminal. I keep getting the "more" sign, until I ctrl+c out of it. – Geo Jul 4 '14 at 22:40
  • oh, I think it worked out after all! I was able to change ONE .htaccess default app. However, when I click on "Change All" to make all other files of this type to open with the same app - I got "The operation can’t be completed (error code -50)" :-( – Geo Jul 4 '14 at 22:48
  • @Geo "-50" is usually permissions/accessibility. Do you have write access? – grg Jul 9 '14 at 18:02
  • that maybe the case.. – Geo Jul 14 '14 at 15:47

"GetFileInfo" is not a separate app, but a process inside the Finder, therefore you cannot use open on it. But you could use the following Applescript:

tell application "Finder" to activate
set thePath to POSIX file "/path/to/file"
tell application "Finder" to reveal thePath
delay 1
tell application "System Events" to keystroke "i" using command down

Now the problem is, that you can not select a file in the Finder that you can not see, making the whole script solution useless if you "do not want to make my hidden files visible. Even temporarily."

But: if you would specify what exactly you're looking for inside the "Get Info" window (e.g. change permissions, get metadata), chances are there's a command line solution for it that works right away.


To open .htaccess or similar dot-files with a specific editor you would have to re-define wich application is the handler for the text/plain mime type or the public.plain-text UTI (for more on the topic of UTIs, see this article for example).

This means that unfortunately .htaccess is viewed the same as .txt by the system and thus both will open with the same editor.

In any case, a comfortable tool to change default file handlers is the preference pane RCDefaultApp which is covered in a lot of questions here on stackexchange.

  • I get "tell: command not found". So Applescript is no good for me either then. What I'm trying to achieve is change the default app that opens that (and many others) type of file when I click on it. – Geo Jul 2 '14 at 16:10
  • 1
    @Geo Applescript is usually executed inside the Applescript editor which resides in /Application/Utilities/, not directly on the command line. I've also updated my answer to reflect your question about file handlers. – Asmus Jul 3 '14 at 6:21
  • the goal of all this is to update my muCommander's (anyone ever used that app?) "Open With.." options. And I don't think it understands Applescript :-( – Geo Jul 3 '14 at 17:25
  • @Geo As I said: unless you want to open all text files with the same editor, it won't work! – Asmus Jul 3 '14 at 17:48
  • ALL text files - fine. RCDefaultApp - no help. I changed it, but it seem to have no effect on the double-click behavior. – Geo Jul 4 '14 at 22:52

Unhide hidden files

The OP does not want to make hidden files visible, I'll keep my answer for the people who do

Use this oneliner to 'un-hide' all hidden files:

defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder

Now you can do a GetFileInfo the way you are used to. Commandi, or File -> Get Info

Hide the hidden files like this:

defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder

Edit: fixed the missing ; sign which resulted in the "Unexpected argument killall; leaving defaults unchanged" error

  • 2
    "I do not want to make my hidden files visible. Even temporarily." – grg Jul 3 '14 at 12:20
  • I was going to downvote. But technically this is a solution after all. So let's keep it. – Geo Jul 3 '14 at 17:28
  • @GeorgeGarside … but Geo commented on my answer that he basically wants to be able to click on an invisible file! How could this be achieved? – Asmus Jul 3 '14 at 17:51
  • "Unexpected argument killall; leaving defaults unchanged." – Geo Jul 7 '14 at 14:12
  • @Geo, thnx fixed the missing ; – CousinCocaine Jul 7 '14 at 14:16

You could use a separate App for displaying and opening the hidden file like Pathfinder or Forklift or even (Open Source/freeware) FTP apps like Filezilla or Cyberduck.

You can select the File and open up the context menu to open/edit the file with whichever program you want.

  • I have Cyberduck. How do I connect to my localhost or select that file? – Geo Jul 3 '14 at 17:27
  • sorry, seems i was mistaken. Cyberduck doesn't have a two pane window. Try Filezilla - there you have a split window with one side showing the local directories, the other showing the server side. – J.C. Jul 4 '14 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .