How can I associate .sh files with Cygwin?

前端 未结 13 1397
旧时难觅i
旧时难觅i 2021-01-29 21:32

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 th

13条回答
  •  Happy的楠姐
    2021-01-29 22:11

    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:

    1. In Explorer, go to Tools/Folder Options/File Types.
    2. I already had an SH entry for Bash Script. If you don't have one, click New and enter "SH" to create one.
    3. With the SH extension selected, click Advanced.
    4. Choose the "open" action and click edit (or create the action).
    5. 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!

提交回复
热议问题