Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Mimic Firefox for Windows' handling of Open With... Web Browsers
In the Windows version of Firefox, if the user selects the "Open with..." option for a file on a webpage, the file is downloaded to the system Temporary files directory before being opened. In the Mac version of Firefox, the file is downloaded to the system downloads directory (The download directory one specifies in Safari and some others browsers, not the one specified in Firefox). This generally means that after viewing the file, you must manually delete it from your drive if you do not wish to keep it.

You can mimic the Windows behaviour simply by changing Safari's download directory to /tmp. To do this, open Safari's General preferences pane and, under Save Downloaded Files To, select Other.... In the dialog that appears, hit Shift-Command-G to bring up the Go to Folder dialog. In this dialog, simply type /tmp, hit OK, then hit Select in the main window.

From this point on, all files for which you select "Open with..." in Firefox will be downloaded to the invisible /tmp directory before being opened. The system clears this directory regularly, so there is no need to worry about manually deleting files you don't want. If you wish to move a file from this directory, you can either enter /tmp in the Finder's Go to Folder" field, or you can command-click in the title bar of an opened file in that directory to see the hierarchy.

[robg adds: Obvious but worth pointing out: if you make this change and then use Safari again, anything you download will also go into /tmp.]
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[15,085 views]  

Mimic Firefox for Windows' handling of Open With... | 8 comments | Create New Account
Click here to return to the 'Mimic Firefox for Windows' handling of Open With...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Mimic Firefox for Windows' handling of Open With...
Authored by: klktrk on Dec 21, '06 11:51:16AM

Should be obvious, but keep in mind, also, that if you're saving downloads to /tmp, any other user on the computer can most likely view your downloads. Could be a problem if you're downloading anything that should be private, like pdfs of sales receipts etc.



[ Reply to This | # ]
Mimic Firefox for Windows' handling of Open With...
Authored by: lar3ry on Dec 21, '06 01:46:44PM
That's doesn't necessarily have to be true.

/tmp links to /private/tmp, which has the mode "rwxrwxrwt" (effectively, 777 + Sticky Bit). The Sticky Bit means that anybody can create files in the directory, but only the owner or root can delete the files. (See "man 8 sticky" within Terminal for the official description of the Sticky Bit.)

So, whether or not anybody can READ your files depends on the default umask employed by Safari. I'm not sure where this information is stored (NetInfo?), but empirically, it appears the default umask may be 644 (rw-r--r--), which means that indeed, anybody might be able to read your files.

[ Reply to This | # ]

Mimic Firefox for Windows' handling of Open With...
Authored by: jeremyp on Dec 22, '06 06:30:15AM

Just a minor point. The umask tells you which bits of the mode are masked out and so has the reverse sense of the mode bits. the default umask is 0022 which gives a mode of 0644 or 0755.

NB you can find out what your umask is by opening a shell and typing "umask" without parameters.



[ Reply to This | # ]
Mimic Firefox for Windows' handling of Open With...
Authored by: mikemcg on Dec 21, '06 02:58:23PM

Interesting tip, and good point in the parent comment. Unfortunately I don't have the time to experiment with this, but I might explore several options to get the best of all worlds:

a) Edit smb.conf to share the /tmp directory, and use a "force create mode" directive to control the umask in that directory. Then auto-mount that share and set the Safari download directory to it (possibly through /Volumes). Or,
b) Add a biweekly cron script, or a routine to the logout script (not sure if this even exist in OS X) that empties the contents of each user's Safari download directory. The uniformity gained by creating a ~/Library/tmp for each user and having Safari (and other applications) use that might also be worth considering.

Hope this helps.



[ Reply to This | # ]
Mimic Firefox for Windows' handling of Open With...
Authored by: Anonymous on Dec 22, '06 08:19:44AM

Samba? Wha? To avoid the potential security risks associated with saving files to a public directory, make a shell script that creates a unique subdirectory in /tmp, say "mkdir /tmp/$USER" and chmods it appropriately. Stuff that in a file called "private_tmp.command" and stuff it in everybody's login items. Finally, change the browser's (Are we talking about Firefox or Safari?) downloads directory to that subdirectory. For each user.



[ Reply to This | # ]
Mimic Firefox for Windows' handling of Open With...
Authored by: mkoistinen on Dec 24, '06 06:53:55AM
First of all, the OP has earned a vote of 5-stars from me, because this is a godsend hint that will prevent my Desktop from getting so cluttered with things I only meant to view/open (I've set Desktop as my Firefox download directory and that's where I will keep it). Secondly, I was indeed concerned about the security of placing things like my bank-statements that I download for viewing, etc. in /tmp, so, following the advice of others, including the guy/gal I'm replying to here. However, I've come up with, I think, an easier solution to manage overall: I've created a folder in /Library/StartupItems called "MkPrivateTmp". You can do this using the following command in a terminal window (click your desktop, then press CMD-SHIFT-U, then open "Terminal"):

sudo mkdir /Library/StartupItems/MkPrivateTmp
Assuming your account is set as an Admin account, enter your own password when prompted. If your account isn't an Admin account, then, well, you're out of luck, ask your administrator to set this up for you.

Inside this folder, you need to create two items: MkPrivateTmp (a script file - this is required to have the same name as the parent folder) and StartupParameters.plist (a required plist file). To create these files, use these commands:

cd /Library/StartupItems/MkPrivateTmp
sudo vi MkPrivateTmp
Then, in vi, press "I", then paste the contents listed below for "MkPrivateTmp" into the shell window, then press ":x". When finished with MkPrivateTmp, do the same for StartupParameters.plist.

MkPrivateTmp

#!/bin/csh

# Simply makes a private directory in tmp for each user
foreach USER (`ls -1 /Users`)
        if ( $USER != 'Shared' && $USER != '.localized' && $USER != '.DS_Store')
        then
                mkdir /tmp/{$USER} 2>&1
                chown {$USER}:{$USER} /tmp/{$USER} 2>&1
                chmod 700 /tmp/{$USER} 2>&1
        endif
end
StartupParameters.plist

//
// MkPrivateTmp
//
{
  Description     = "Provides a private /tmp directory for each user";
  Provides        = ("MkPrivateTmp");
  OrderPreference = "Early";
  Messages =
  {
    start = "Making per-user private directory in /tmp...";
  };
}
Now, set the ownership and permissions appropriately as follows:

sudo chown -R root:wheel /Library/StartupItems/MkPrivateTmp
sudo chmod -R 755 /Library/StartupItems/MkPrivateTmp
sudo chmod u+x /Library/StartupItems/MkPrivateTmp/MkPrivateTmp
Now, just reboot and /tmp will automatically have one folder per Mac-user with permission set only for him/her to read write and examine the contents of this private tmp folder. Now, in Safari, set the download directory to "/tmp/[yourusername]" instead of just "/tmp" and voila, you're in business. From now on, when you open a download in Firefox, it will indeed open, but it will not leave the download in your download folder (Desktop, for me). However, when you download a file, it will indeed, be placed wherever you've configured Firefox's downloads to go (again, Desktop, for me). I hope this helps someone else!

[ Reply to This | # ]
Mimic Firefox for Windows' handling of Open With...
Authored by: kerouassady on Dec 27, '06 10:46:59PM
Not exactly sure if this is correct or not, but I think the Add-On 'OpenDownload' will accomplish this.

https://addons.mozilla.org/firefox/207/

It lets you choose to open downloads with the default OS designated app. When I use it (say, to open dmg files automatically like Safari does), it downloads to a moztemp directory instead of the Downloads directory. I guess it tells the OS to open it, intercepting it before Firefox has a chance to fully write the download to the Downloads directory.

[ Reply to This | # ]
Mimic Firefox for Windows' handling of Open With...
Authored by: almostHandsome on Jun 10, '09 09:53:17AM

This is one of my favorite hints. It works just fine on my Mac Mini running OS 10.4, but when I try to install on my friend's iMac, also running OS 10.4, it never works.

I just re-installed this on my system after getting the hard drive replaced, so I remember exactly what I did. But it still doesn't work on this guy's iMac.

PS: There is one little change I had to make, to get it to work on my Mac. In that csh script, I had to put the 'then' keyword on the same line as the 'if' statement. My system complained about a syntax error until I made this change.



[ Reply to This | # ]