How can I associate .sh files with Cygwin?

bash, cygwin, windows

Solution

Ok, I've found something that works. Associating a batch file as Vladimir suggested didn't work, but the bash arguments were key.

Short and sweet: associate with this command: "C:\cygwin\bin\bash.exe" -li "%1" %*

Long version if you don't know how:

- In Explorer, go to Tools/Folder Options/File Types.

- I already had an SH entry for Bash Script. If you don't have one, click New and enter "SH" to create one.

- With the SH extension selected, click Advanced.

- Choose the "open" action and click edit (or create the action).

- This is the command to use: "C:\cygwin\bin\bash.exe" -li "%1" %*. Note that without the -li, it was returing "command not found" on my scripts.

You may also want to add SH to your PATHEXT environment variable:

WinKey+Pause / Advanced / Environment Variables / System Variables / PATHEXT

Thanks for your help, guys!

Problem

I'd like to run a long rsync command in Cygwin by double clicking on a .sh file in Windows. It must start in the file's containing directory (e.g. /cygdrive/c/scripts/) so that relative paths work. Anyone gotten this to work? Note: I've just found here, a Cygwin package that manages Windows context menus (Bash Prompt Here). It might have some clues.

Original source