Search code examples
bashcygwinphpstorm

cygpath to phpstorm.bat function fails


I'm using cygwin to fire up PhpStorm from the command line. Everything works but in order to do it I have to first run

crntproj=$(cygpath -w $PWD)

and then run

phpstorm.bat $crntproj

What I'd prefer is to be able to simply run phpstorm.bat $PWD except that doesn't work.

So I've written a bash function as follows and added to my bashrc:

function winpath {
path=$(cygpath -m $PWD)
echo $path
}

Strangely this returns what appears to be the correct folder but when I run phpstorm.bat winpath PhpStorm tries to open C:/user/project/winpath which of course doesn't exist.

I've now tried both -w for windows and -m for mixed. That makes no difference. I also concatenated a forward slash at the end of the path to tell PhpStorm that its a folder and not a file. This also didn't fix the problem.

Can anyone explain what I'm missing?


Solution

  • Okay so put the following in .bash_profile and it works perfectly now

    function winpath {
    path=$(cygpath -m $PWD)
    echo $path
    }
    

    now just run phpstorm.bat $(winpath)

    I've even made a couple of aliases to make it easier

    alias pstorm='phpstorm.bat'
    alias pstorm-openProj='pstorm $(winpath)'
    

    So now I can just run pstorm-openProj in the project folder