The company I work at, like many, uses Windows for our workstation PCs. I much prefer developing in Linux, and so do most of my day-to-day work in a virtual machine. (I love VirtualBox’s Seamless Window feature for this). I do my work in a VirtualBox shared folder, which means that it is actually a folder on the host OS, but can be mounted in the guest OS as well. This makes the files I work on in Linux easily accessible from Windows too.
Sometimes I’m plugging away in a Linux shell and want to do something in the same directory on the Windows host. I quickly got tired of opening explorer (the Windows file browser) and navigating down to the directory I was working in under Linux, so I came up with a reasonable 2-step process to quickly open an explorer window in the current Linux directory. (We use Windows 7 at work, but I think a similar process should work for other Windows versions).
I wrote a script in Linux that creates a Windows batch file. When passed an argument, the script causes the batch file to open Windows explorer in the directory specified by the argument. Otherwise it uses the present working directory. The batch file is created in the root of the shared folder. Each time the script is run it overwrites the old batch file so that the same file now points to a new location.
Here are the steps to make this work in your environment:
Download the script and put it in a directory that is in your Linux $PATH so it is easy to use from anywhere.
Edit the script to match your VirtualBox setup:
change the “HOSTSHARE” variable at the top to be the shared directory path on your Windows host machine.
change the “SHAREMOUNT” variable at the top to be the mountpoint for the shared directory on your Linux guest machine
chmod u+x winthis.sh
Now the two-step process to open the current directory in Windows is:
Type “winthis.sh” in the Linux shell
Click the shortcut on the Windows toolbar to open the directory
Now you can quickly drag the file to attach it to an Outlook e-mail or whatever else you need to do with it in Windows.
If you want to change the icon for the toolbar link, you need to do it before you pin it to the toolbar. After you create the shortcut, bring up the properties and click the “Change Icon…” button.
You can delete the original shortcut after you have dragged it to the taskbar (but not the target batch file, of course).
I learned about the pinnable shortcut trick from a lifehacker tip.
At first I thought it would be simpler to avoid the batch script and just create the link directly. However, Windows “link” files are some complicated binary format, so I quickly gave up looking into that. After completing the process, I’m not sure it would have worked anyway, as from Linux I couldn’t directly modify the shortcut that lives on the Windows toolbar.