Open the MSYS Shell Right Where You Want It

Monday, January 03 2005 @ 12:49 AM PST

Contributed by: Admin

In PDF Hacks, I devised a fast way to open a Windows command prompt in any selected folder (see Hack #79, "Tool Up with pdftk"). It is a right-click menu item called "Command" that I added to the "Folder" (not the "File Folder") file type. Select "Command," and a Windows command prompt opens up and it is set to that working directory. It is a fast way to open a folder of PDFs for processing with pdftk.

Since then, I have been using MSYS and its Bourne shell (a/k/a bash) more and more on my Windows machine. Tonight I finally got around to creating a handy, right-click menu item for MSYS. Read on to learn how.

These instructions are written for Win2k and WinXP users. Other Windows users will need to use command.com instead of cmd.exe. I have tested this only on my Win2k machine; your mileage may vary.

Edit c:msys1.0etcprofile

First, you'll need to edit c:msys1.0etcprofile. This is the script first executed by sh.exe when you launch msys.bat. We want it to change to the directory we pass in, if any. We'll use the environment variable NEWDIR for our passed-in directory name. So simply append the line cd "$NEWDIR" to profile. E.g., where it now says:

  cd "$HOME"

Change it so it says:

  cd "$HOME"
  cd "$NEWDIR"

Add an "Open MSYS" Action to the Folder File Type

Again, I want to emphasize we are adding this action to the "Folder" file type, not the "File Folder" file type.

  1. Open the Windows File Explorer.
  2. Select Tools > Folder Options.
  3. Select the "File Types" tab.
  4. Select the "Folder" file type and click the "Advanced" button.
  5. Click New...
  6. Name the new action: "Open MSYS",
  7. Under "Application used..." enter:
    cmd.exe /K cd /D c:msys1.0 && set NEWDIR=%1 && msys.bat
    
  8. Click OK, OK, and Close.

To test it, right click a folder in the Windows File Explorer. The context menu that opens should include your new item: "Open MSYS". Select this item, and MSYS should open a shell and set the directory to that location.

13 comments



http://www.accesspdf.com/article.php/20050103004905415