Search code examples
windowsintellij-ideash

How to run .sh script in Intellij in Windows


I have a problem about running sh file in Intellij in Windows.

When I clicked the run button in the file, I got this output shown below.

PS C:\Users\username\IdeaProjects\library> /bin/sh C:/Users/username/IdeaProjects/library/aws-setup.sh
/bin/sh : The term '/bin/sh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify t
hat the path is correct and try again.
At line:1 char:1
+ /bin/sh C:/Users/username/IdeaProjects/library/aws-setup.sh
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (/bin/sh:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

How can I fix it?


Solution

  • Set Settings (Preferences on macOS) | Tools | Terminal | Shell path to c:\Program Files\Git\bin\bash.exe or use Shell Script run configuration with Interpreter path set to bash.exe:

    bash